I’m trying to insert a new record into a table ‘order’. Here is the code:
$orderDB = mysql_query("INSERT INTO order (itemsID, deliveryDestinationID, total, shipped) VALUES ($itemID, $delivery, $totalprice, 'N')") or die(mysql_error());
The variables are $itemID which is a 5 digit number, $delivery which is also a 5 digit number, $totalprice which is the cost of the transaction (e.g. 137.97) and ‘N’ which is used in a shipped field in my table.
I think the issue is coming from $totalprice, however when I echo all the variables before this line they appear to be correct. Here is an example of the echo’s and error when $totalprice is 170:
00036 00022 N 170 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘order (itemsID, deliveryDestinationID, total, shipped) VALUES (00036, 00022, 170’ at line 1
Any ideas?
orderis a reserved word in MySQL. Consider changing the table name or wrap it in backticks (eg:`order`)http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html