當我插入具有撇號的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