Gammu 错误插入收件箱



此MySQL查询错误在插入我的inbox表中时发生。

发件人编号列中出现错误,因为值为"WENDY'S"。

如何编辑 MySQL 语法以插入 Gammu 中的收件箱?
我已经尝试过了,但这不起作用: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])

看起来像一个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中转义字符串的官方文档。

相关内容

  • 没有找到相关文章

最新更新