With a the code,
mysql_query("INSERT INTO Messages (Message, toUser, From, Date) VALUES ('$mes','$to','$from','$date')")
I’m getting an SQL syntax error. What is the reason for this? I see nothing wrong with the syntax.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
DATEis a reserved word in SQL, so I gather that it’s triggering a syntax error when you use it as a column name because MySQL tries to parse it as something other than a column name.Either escape your identifiers with backticks:
Or better, see if you can rename the column to something else that doesn’t need escaping.