tags:

views:

60

answers:

4

I get this error: 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 (total, addy, cc) VALUES ('798' , '123 sadf' , '12124123')' at line 1

$total = addslashes(($_SESSION['total']));

$addy = addslashes(($_POST['addy']));

$cc = addslashes(($_POST['cc']));

echo "$total";

echo "$addy";

echo "$cc";

mysql_query("INSERT INTO order (total, addy, cc) VALUES ('$total' , '$addy' , '$cc')") or die(mysql_error());

help plz =]

+6  A: 

order is reserved word.

INSERT INTO `order`
Col. Shrapnel
+3  A: 

The reason why this is failing is because "order" is a keyword in SQL.

You need to put backticks around table names to avoid problems like these.

Jacob Relkin
+2  A: 

Try putting ticks around order

`order`
Galen
A: 

You forgot "$connection"

mysql_query("INSERT INTO order (total, addy, cc) VALUES ('$total' , '$addy' , '$cc')",$connection) or die(mysql_error());
Vimard
"$connection" is the thing that is causing that problem...
Vimard
sorry pal, you have no clue
Col. Shrapnel
@Vimard: Col. Shrapnel is correct. The fact that he is getting a MySQL error shows that the connection is already established. The mysql_query() function uses an already established connection by default if one is not specified. The connection is not an issue. Read the manual -> http://us2.php.net/manual/en/function.mysql-query.php
Joseph
@Joseph: thanx dude.. you are right...
Vimard