GB_001 Posted May 19, 2008 Share Posted May 19, 2008 Hello, I keep getting a mysql syntax error with this piece of code. $query = "INSERT INTO Order (FirstName, LastName, Address, NOShirts, NOCaps, NOTickets, Price) VALUES('$FN', '$LN', '$address', '$Stotal', '$Ctotal', '$Ttotal', '$P')"; mysql_query($query) or die(mysql_error()); Thankyou, GB. Link to comment https://forums.phpfreaks.com/topic/106245-syntax-error/ Share on other sites More sharing options...
DarkWater Posted May 19, 2008 Share Posted May 19, 2008 What syntax error exactly? =/ Link to comment https://forums.phpfreaks.com/topic/106245-syntax-error/#findComment-544543 Share on other sites More sharing options...
GB_001 Posted May 19, 2008 Author Share Posted May 19, 2008 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 (FirstName, LastName, Address, NOShirts, NOCaps, NOTickets, Price) VALUES' at line 1 That's the error. Link to comment https://forums.phpfreaks.com/topic/106245-syntax-error/#findComment-545305 Share on other sites More sharing options...
AndyB Posted May 19, 2008 Share Posted May 19, 2008 order is a MySQL reserved word. You should avoid using reserved words as the names of database tables or fields. http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html I'd suggest changing the table name, but - if this is a large application already - you could use `backticks` around order and avoid the problem rather than re-write some code. Link to comment https://forums.phpfreaks.com/topic/106245-syntax-error/#findComment-545309 Share on other sites More sharing options...
GB_001 Posted May 19, 2008 Author Share Posted May 19, 2008 Thankyou. =). Link to comment https://forums.phpfreaks.com/topic/106245-syntax-error/#findComment-545315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.