[英]What's wrong with this SQL query?
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.所有变量都通过 PHP 发布。 This is the error sql echoes when it dies:
这是 sql 死亡时回显的错误:
You have an error in your SQL syntax;您的 SQL 语法有错误; 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
检查与您的 MySQL 服务器版本相对应的手册,以了解在“发件人、回复、主题、收件人、消息、日期”附近使用的正确语法(第 1 行的“First Last”、“First.La”
Here is the structure of my SQL database...这是我的 SQL 数据库的结构...
http://img21.imageshack.us/img21/3940/sqlerror.png 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.
我有这个错误很奇怪,因为我从 w3schools 获得了示例代码。 Any suggestions?
有什么建议么?
from
is a reserved word and needs to be escaped with backticks. from
是保留字,需要用反引号转义。
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.您需要转义关键字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.