繁体   English   中英

无法弄清楚mySQL语法错误的来源

[英]Can't figure out source of mySQL syntax error

我正在我的网站上的用户之间的私人消息系统。 这是我的查询:

$query = "INSERT INTO messages (to, `from`, message) VALUES ('{$user}', '{$username}', '{$message}')";

但是,我收到此错误:

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 'to, `from`, message) VALUES ('Cheezey', 'Cheezey', 'Enter your message here')' at line 1

我有一种唠叨的感觉,这对我来说是一个非常愚蠢的错误,但我似乎无法弄明白。

这是因为to为一个保留字在MySQL中,你必须把'它周围,像这样:

 INSERT INTO(`to`, ...).

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM