eggy524 Posted February 26, 2007 Share Posted February 26, 2007 Hi, I'm creating a small shopping cart system with php and MySQL and need some help. I have a table in MySQL called 'order' with fields: OrderID int(10) - SET AS PRIMAY KEY AND TO AUTO-INCREMENT Username varchar(30) OrderDate Paid int(1) DIspatched int(1) I want to add a row to this table so in php I use this code: $current_date = date('Y-m-d'); $sql = "INSERT INTO order (Username, OrderDate) VALUES ('$username' , '$current_date')"; $result = mysql_query($sql); if(!$result) { die(mysql_error()); } else { echo 'OK'; } As far as i know, the fields below do not need to be inserted in my query because they have default values or otherwise: OrderID - should automatically increment Paid - Default value set to 1 Dispatched - Default value set to 0 The problem is that when i run this query I get the error message: 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 WHERE Username='test'' at line 1 I cant see anything wrong with this query, does anyone have any ideas? Thanks, adamport Link to comment https://forums.phpfreaks.com/topic/40224-sql-query-problem-with-php/ Share on other sites More sharing options...
Barand Posted February 26, 2007 Share Posted February 26, 2007 ORDER is a reserved word ( as in ORDER BY) Link to comment https://forums.phpfreaks.com/topic/40224-sql-query-problem-with-php/#findComment-194674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.