bsamson Posted June 20, 2007 Share Posted June 20, 2007 I have a table within the database, nnyserve_main. The table is called: ebdopt. I have 3 fields, id, cat, and option. I keep getting the following syntax 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 'option) VALUES ('', 'Data Services', '453')' at line 1 Here's the script: <? $cat = "Data Services"; $option="453"; // connection information $hostName = "localhost"; $userName = "nnyserve_main"; $password = "MYPASSWORDHERE"; $dbName = "$dbname"; // make connection to database mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName"); mysql_select_db($dbName) or die( "Unable to select database $dbName"); mysql_query("INSERT INTO ebdopt(id, cat, option) VALUES ('', '$cat', '$feature')") or die (mysql_error()); ?> I am running MySQL version: 5.0.37 w/ php 5. For the life of my I cannot find the error! Any assistance would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/56430-solved-mysql-insert-issues/ Share on other sites More sharing options...
akitchin Posted June 20, 2007 Share Posted June 20, 2007 option is a reserved keyword, and as such, cannot be used as a field name. while it may not trip up the table creation query, it will trip up any data manipulation statements involving that field. http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html PS: when wanting to let MySQL assign an ID automatically, you can just drop it from the INSERT statement rather than sending it an empty value. Link to comment https://forums.phpfreaks.com/topic/56430-solved-mysql-insert-issues/#findComment-278695 Share on other sites More sharing options...
bsamson Posted June 20, 2007 Author Share Posted June 20, 2007 THANKS! You know, I knew it was going to be something simple ... eeerrr. Thanks for the advice! Link to comment https://forums.phpfreaks.com/topic/56430-solved-mysql-insert-issues/#findComment-278705 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.