1

this is the php code:

$stringquery = "INSERT INTO sikurim(name, title, desc, category, subcategory)

 VALUES ('$contact', '$heading','$comments', '$catF', '$catS' ) ";

mysql_query($stringquery) or die(mysql_error());

And i get the 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 'desc, category, subcategory) VALUES ('jhjh', ' fffff','fffff', '2', '4' )' at line 1

I can't find what's wrong with the code, can someone help?

2 Answers 2

8

DESC is reserved MySQL keyword. You need to enclose it in backquotes:

$stringquery = "INSERT INTO sikurim(name, title, `desc`, category, subcategory) VALUES ('$contact', '$heading','$comments', '$catF', '$catS' )";
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, but the best would definitely be to change the column's name.
and please make sure you apply proper sanitation to your variables if you are interpolating them to your query!
0

You should escape each value. Use mysql_escape_string http://www.php.net/manual/en/function.mysql-escape-string.php

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.