我正在尝试使用 node-mysql转义查询值,但是当我尝试将其插入到我的 MySQL 查询中时,我遇到了错误并且似乎找不到问题。我也尝试过以不同的方式布置代码,就像在我链接的 github 示例中看到的那样。
错误:
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 'don\\'t spam!''' at line 1
banReason = 不要垃圾邮件!
var banr = con.escape(banReason)
let sql
sql = `INSERT INTO modlog (senderid, victimid, duration, releasedate, reason) VALUES ('${message.author.id}', '${user}', '${timeCode}', '${moment().add(timeValue, timeType)}', '${banr}'`
con.query(sql)