插入我的inbox
表时会发生此MySQL查询错误。
SenderNumber列中的错误,因为值'WENDY'S'。
如何编辑用于插入Gammu收件箱的MySQL语法?
我已经尝试了这个,但这不起作用:https://wammu.eu/docs/manual/smsd/sql.html#configurable-queries
Fri 2018/04/20 16:21:54 gammu-smsd[4760]: SQL failed: INSERT INTO inbox (ReceivingDateTime, Text, SenderNumber, Coding, SMSCNumber, UDH, Class, TextDecoded, RecipientID) VALUES ('20180420092816','00420065006C00690020004E0061007300690020002B0020004100790061006D002000430075006D0061002000520070002E00310038002E003100380032002000640069002000570065006E00640079002700730021002000540075006B00610072006B0061006E00200053004D005300200069006E00690020007300650067006500720061002000640069002000730065006C00750072007500680020006F00750074006C00650074002000570065006E00640079002700730021002000530026004B0020004200650072006C0061006B0075002E002000500072006F006D006F0020002A0036003000360023','WENDY'S','Default_No_Compression','+6281100000','','1','Beli Nasi + Ayam Cuma Rp.18.182 di Wendy\'s! Tukarkan SMS ini segera di seluruh outlet Wendy\'s! S&K Berlaku. Promo *606#','com6-simpati')
Fri 2018/04/20 16:21:54 gammu-smsd[4760]: Error code: 1064, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'S','Default_No_Compression','+6281100000','','1','Beli Nasi + Ayam Cuma Rp.18.18' at line 1
Fri 2018/04/20 16:21:54 gammu-smsd[4760]: Error writing inbox message to database (SMSDMySQL_SaveInboxSMS)
Fri 2018/04/20 16:21:54 gammu-smsd[4760]: Error processing SMS: Unknown error. (UNKNOWN[27])
答案 0 :(得分:0)
这看起来像是一个MySQL问题。查看错误日志中的查询(使用一些格式,并删除长值以获得易读性):
INSERT INTO inbox (
ReceivingDateTime
, Text
, SenderNumber
, Coding
, SMSCNumber
, UDH
, Class
, TextDecoded
, RecipientID)
VALUES (
'20180420092816'
,'....'
,'WENDY'S'
,'Default_No_Compression',
'+6281100000',
'',
'1',
'Beli Nasi + Ayam Cuma Rp.18.182 di Wendy\'s! Tukarkan SMS ini segera di seluruh outlet Wendy\'s! S&K Berlaku. Promo *606#',
'com6-simpati')
SenderNumber
的值为'WENDY'S'
。计算机认为字符串在WENDY之后结束,然后在期望逗号和下一个值时看到另一个字符。出现错误。
你应该转义字符串:'WENDY''S'
应该做的伎俩。
有关MySQL中转义字符串的一些官方文档是here。