[英]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.