Zephni Posted September 1, 2011 Share Posted September 1, 2011 Hello guys, I do hundreds of INSERT INTO's I work for a web development company and maybe I shouldn't coz' this is embarrassing. This is my INSERT: $query_add_refference = mysql_query("INSERT INTO references VALUES ('','$name','$value')")or die(mysql_error()); The error I am getting is: 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 'references VALUES ('','NameTest','ValueTest')' at line 1 I cannot see the syntax error myself :s maybe its just been a long day at work anyone have any idea's? ALSO my biggest question is... Why is it saying the error is at line 1? The mysql query is on line 7 :s This happened to me once before.. Thank you very much for your answers Quote Link to comment Share on other sites More sharing options...
Maq Posted September 1, 2011 Share Posted September 1, 2011 'references' is a MySQL reserved word. You need to either put backtics around it `references` or change the table name. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 1, 2011 Share Posted September 1, 2011 The point in the query that the error message is calling your attention to is where mysql found something in your query that is out of place or means something else to mysql. Hmmm. I wonder what about the word references could cause this (see this link for a list of mysql reserved keywords - http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html ) Edit: Posted anyway... Quote Link to comment Share on other sites More sharing options...
Zephni Posted September 1, 2011 Author Share Posted September 1, 2011 Thank you v much thought I was going insane (Also sorry I posted in wrong forum). Would be nice if mysql_error() told me it was a reserved word. Any idea's why it was telling me the error was on line 1? Quote Link to comment Share on other sites More sharing options...
DavidAM Posted September 1, 2011 Share Posted September 1, 2011 That error message is coming from the database server. You only sent one line of code to the server, so the error is on line 1 (of the query). The database knows nothing of your PHP script. INSERT INTO references VALUES ('','$name','$value') This should report the error on line 2 Quote Link to comment Share on other sites More sharing options...
fenway Posted September 1, 2011 Share Posted September 1, 2011 And you should really include the column list. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.