Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/246195-mysql-syntax-error-on-insert-into/
Share on other sites

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...  :)

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.