mysql_query("INSERT INTO scheduler (from, reply, subject, recipients, message, date) VALUES ('$from_name', '$reply_to', '$subject', '$parsedemail', '$body', '$date')")or die (mysql_error());
All the variables are posted via PHP. This is the error sql echoes when it dies:
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 'from, reply, subject, recipients, message, date) VALUES ('First Last', 'First.La' at line 1
Here is the structure of my SQL database...
http://img21.imageshack.us/img21/3940/sqlerror.png
I think I've remade it and renamed stuff a lot of times now. It has to be something obvious. It's weird I'm having this error because I got the sample code from w3schools. Any suggestions?
from
is a reserved word and needs to be escaped with backticks.
mysql_query("INSERT INTO scheduler (`from`, reply, subject, recipients, message, date) VALUES ('$from_name', '$reply_to', '$subject', '$parsedemail', '$body', '$date')")or die (mysql_error());
mysql_query("INSERT INTO scheduler (`from`, reply, subject, recipients, message, `date`) VALUES ('$from_name', '$reply_to', '$subject', '$parsedemail', '$body', '$date')")or die (mysql_error());
You need to escape keywords.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.