0

I have been very confused on what is wrong with this php code, it only gives me blank pages.

$sql = "INSERT INTO `mosys`.`allcheck` 
(`cDate`, 
    `cCheckNo`, 
        `cClass`, 
            `cPayee`, 
                `cPayeeAddress`, 
                    `cSender`,
                        `cSenderAddress`, 
                            `cAmount`) 
VALUES (".getDateTime()."', 
        '$_POST[cCheckNo]', 
            '$_POST[cClass]', 
                '$_POST[cPayee]', 
                    '$_GET[cPayeeAddress]',
                        '$_POST[cSender]', 
                            '$_POST[cSenderAddress]', 
                                '$_POST[cAmount]');";

}

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
}

What seems to be wrong?

here is the layout link and the php link

7
  • 2
    insert doesn't return anything. Commented Jul 12, 2014 at 16:13
  • 1
    What should it be outputting? It'll only print something if the query fails. Do you mean that it's not inserting anything, and you're not getting an error? Commented Jul 12, 2014 at 16:14
  • Do not forget SQL injection7 Commented Jul 12, 2014 at 16:15
  • @andrewsi its not inserting anything on the database and also not showing error Commented Jul 12, 2014 at 16:17
  • @ElyBesiño - what is the error in die Commented Jul 12, 2014 at 16:21

2 Answers 2

2

In your PHP Code is just one output declared: die(); So when there is no error, i think your code works well. Why are you expecting something else then a blank page?

Sign up to request clarification or add additional context in comments.

1 Comment

if there is no error then it should insert something, but it does not insert anything and show no error
0

Please try this:

$sql = "INSERT INTO mosys.allcheck 
(cDate, 
    cCheckNo, 
        cClass, 
            cPayee, 
                cPayeeAddress, 
                    cSender,
                        cSenderAddress, 
                            cAmount) 
VALUES ('".getDateTime()."', 
        '".$_POST[cCheckNo]."', 
            '".$_POST[cClass]."', 
               '".$_POST[cPayee]."', 
                    '".$_GET[cPayeeAddress]."', 
                        '".$_POST[cSender]."', 
                            '".$_POST[cSenderAddress]."', 
                                '".$_POST[cAmount]."')";

}

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
}

3 Comments

what's the table name you want to insert in ?
table name is allcheck with cCheckNo as primary
here is the layout link and the php link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.