orionellis Posted March 9, 2007 Share Posted March 9, 2007 I have a query that will not insert! I know I am doing something wrong but I can't see it. I suspect it is the query based on the error below. <?php mysql_connect("localhost", "root", "fakepassword") or die(mysql_error()); mysql_select_db("orderboard") or die(mysql_error()); // Insert a row of information into the table $query = "INSERT INTO order (r_fname, r_lname, r_descript, r_quantity, r_website, r_date, r_status, r_po ) VALUES ('jim',ellis','Pencil Cup','12','www.yahoo.com','12/23','pending','00000')"; mysql_query($query) or die(mysql_error()); ?> Here is the error I am getting: 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 (r_fname, r_lname, r_descript, r_quantity, r_website, r_date, r_status, r_' at line 1 Link to comment https://forums.phpfreaks.com/topic/42053-is-there-something-wrong-with-this-query/ Share on other sites More sharing options...
per1os Posted March 9, 2007 Share Posted March 9, 2007 Yep, order is a reserved word in MySQL, I would change the table name to orders or rorder or %YOURPREFIXHERE%_order --FrosT Link to comment https://forums.phpfreaks.com/topic/42053-is-there-something-wrong-with-this-query/#findComment-203945 Share on other sites More sharing options...
orionellis Posted March 9, 2007 Author Share Posted March 9, 2007 Frost100, You are a friggin genious man. I have posted this problem on several boards and no one could figure it out. You are the (Wo)man (orionellis bows). Thank you. Thank you. Thank you. Hours and hours of misery have met their end. I am going to start a paypal account today to donate in the future. Link to comment https://forums.phpfreaks.com/topic/42053-is-there-something-wrong-with-this-query/#findComment-203948 Share on other sites More sharing options...
jcbarr Posted March 9, 2007 Share Posted March 9, 2007 In most cases simply enclosing order in ` ` will work as well. I had to do this for one of my tables in the past. Putting something in ` ` will make the server treat it as a name rather than a recgonized command or reserved word. Link to comment https://forums.phpfreaks.com/topic/42053-is-there-something-wrong-with-this-query/#findComment-203949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.