[英]simple mysql query
$to = '555';
$from = '555';
$message = 'stuff';
mysql_query("INSERT INTO `convo` (to, from, content)
VALUES ( '$to', '$from', '$message' )") or die(mysql_error());
I can't figure out what is wrong with my above simple query. 我无法弄清楚上述简单查询出了什么问题。 What obvious thing am I missing? 我想念什么明显的东西?
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 'to, from, content) VALUES ( '555', '555', 'stuff' )' at line 1 检查与您的MySQL服务器版本相对应的手册以获取在第1行的'to,from,content'VALUES('555','555','stuff')'附近使用的正确语法
It looks like to
is a MySQL reserved word. 它看起来像to
是一个MySQL的保留字。
Try 尝试
mysql_query("INSERT INTO `convo` (`to`, `from`, `content`) VALUES ( '$to', '$from', '$message' )") or die(mysql_error());
TO is a MySQL keyword. TO是一个MySQL关键字。 To fix this, wrap backticks around your to field. 要解决此问题,请在您的字段周围加上反引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.