sql - 'ER_PARSE_ERROR' on node mysql when inserting multiple values -



sql - 'ER_PARSE_ERROR' on node mysql when inserting multiple values -

i'm trying set in multiple values database using node-mysql in node. source code

engine.files.foreach(function(file) { torrentpath = file.path.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/\\/g, "/"); torrentfiles.push([ result.insertid, torrentpath, file.length ]); }); console.log(torrentfiles); app.mysql.query('insert `files` (`torrentid`, `filename`, `filesize`) values ?', torrentfiles, function(err, result) { if (err) throw err; });

the error is

[ [ 11, 'ubuntu-14.04-desktop-amd64.iso', 1010827264 ] ] error: er_parse_error: have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '11, 'ubuntu-14.04-desktop-amd64.iso', 1010827264' @ line 1 @ query.sequence._packettoerror (c:\wamp\www\sleepytorrentdownload\src\node_modules\mysql\lib\protocol\sequences\sequence.js:30:14)

currently of other sql queries seem work connected database. if more info needed, i'll gladly give them. dont know more set on here.

i ended using mysql.escape(val) within query

app.mysql.query('insert `files` (`torrentid`, `filename`, `filesize`) values '+app.mysql.escape(torrentfiles), function(err, result)

edit

the prepare add together set torrentfiles in []. now

app.mysql.query('insert `files` (`torrentid`, `filename`, `filesize`) values ? ', [torrentfiles], function(err, result)

mysql sql node.js node-mysql

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -