当我插入具有撇号的HTML输入我得到这个错误ER_PARSE_ERROR
Error: ER_PARSE_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
例如一个字:插入文字没有像撇号的“Hello world”的作品成功地和我能看到MySQL表中的行。但是,当我插入“这是”的话,那么我得到的错误。
我使用varchar作为值行。
connection.query("INSERT INTO masstoadmin (`title`,`contact`,`theuser`,`ptime`,`touser`,`mass_stat`) VALUES ('"+title+"','"+contact+"','"+theuser+"','"+ptime+"','"+tuser+"','"+nmasso+"')");
了解SQL注入和[如何逃脱值(HTTPS ://github.com/mysqljs/mysql#escaping-query-values)。 – robertklep
@robertklep我试图使用connection.escapeId,我仍然得到错误 –
可能重复[INSERT INTO失败与节点mysql](https://stackoverflow.com/questions/21779528/insert-into-fails-with- node-mysql) – Veve