1

I don't know what's wrong with my syntax, but I'm missing something:

$createrequest = mysql_query("INSERT INTO products_updates_queue (id, kid,
product_version_id, key, ip) VALUES ('$request_id', '$uid', '$version_id',
'$request_key', '$request_ip')");

I receive this 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 'key, ip) VALUES ('j4ctveyd0x62', '1', 'z451ah3', 'hqbyu7bhg8za', '64.134.163.2' at line 2"

Can anyone see what I am missing?

2 Answers 2

6

I think key is a reserved word, and you should avoid using it as a column name. Try using backticks around it:

$createrequest = mysql_query("INSERT INTO products_updates_queue (id, uid, product_version_id, `key`, ip) VALUES ('$request_id', '$uid', '$version_id', '$request_key', '$request_ip')");
Sign up to request clarification or add additional context in comments.

3 Comments

+1 for suggesting avoiding using it as a column name (Better solution then always having to wrap it in backticks)
Thanks for your reply! I saw the solution from @DCoder before yours, but I will accept yours so that others (if they have the same problem), will know to avoid using this column name.
The other user also tells you to avoid it. Feel free to accept the answer you like the most!
3

key is a reserved word in MySQL. Avoid it, or wrap it in backticks.

Edit: And I hope you escaped the variables you're putting into that query.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.