0

我的查询有问题,有人看到不好的东西吗?

INSERT INTO messages (subject, from, recipient, text, time)
VALUES
('Welcome in King of the States!','The Game','$username','Hello $username, THIS MESSAGE IS DISPLAYED IN ENGLISH AUTOMATICLY SORRY FOR THAT! this game is in baby stadium so if you will see any bugs, please report them to our help desc system','$time')

来自 sql 的错误:

#1064 - 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, recipient, text, time) VALUES ('Welcome in King of the States!','The Gam' at line 1
4

5 回答 5

2

from是 mysql 的保留字。尝试放置from反引号

如下所示:

`from`
于 2013-10-11T13:03:20.910 回答
1

试着做:

INSERT INTO messages (`subject`, `from`, `recipient`, `text`, `time`)
VALUES
('Welcome in King of the States!','The Game','$username','Hello $username, THIS MESSAGE IS DISPLAYED IN ENGLISH AUTOMATICLY SORRY FOR THAT! this game is in baby stadium so if you will see any bugs, please report them to our help desc system','$time')
于 2013-10-11T13:03:36.660 回答
1

From 是 mysql 中的保留关键字,因此请使用以下查询:

INSERT INTO `messages` (`subject`, `from`, `recipient`, `text`, `time`)
VALUES
('Welcome in King of the States!',
 'The Game','$username',
'Hello $username, 
THIS MESSAGE IS DISPLAYED IN ENGLISH AUTOMATICLY SORRY FOR THAT! this game is in baby stadium so if you will see any bugs, please report them to our help desc system','$time')
于 2013-10-11T13:03:57.297 回答
0
"INSERT INTO messages SET subject='Welcome in King of the States!',from='The Game',recipient='".$username."',text='Hello.$username', time=''";
于 2013-10-11T13:20:27.583 回答
0

操作说明:

from 是 mysql 中的一个关键字。所以你不能像这样直接在查询中使用。您需要每次都解析它并为此使用反引号

像使用它一样 from

于 2013-10-11T13:25:03.760 回答