Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT should be perfect but returns an error

Status
Not open for further replies.

phpgramma

Programmer
Dec 24, 2004
35
0
0
US
So here's my query:
Code:
$sql="INSERT INTO news (date,time,member_id,chapter_id,headline,article,show) VALUES ('$date','$time','$poster_id','$chapter_id','$headline','$article','$show')";
but for some reason I keep getting 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..."
and can't figure out why. I checked the database- fields are in the correct format and all of the variables, fields are named correctly in the statement...?

 
It might be because you're using "show" and "date" as column names. SHOW and DATE are both MySQL reserved words.

You have two options:[ol][li]Pick better column names that don't use MySQL reserved words[/li][li]enclose those column names in backticks, which will let MySQL know they are not to be interpreted as reserved words[/li][/ol]

I strongly recommend the former.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top