Categories
express mysql node.js prepared-statement

Set multiple fields in prepared queries in NodeJS

I am using ‘mysql’ library in Node

This is what i use instead of prepared statement, and works just fine :

 connection.query("update table set col1=? where col2=1",[val1],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});

However, this doesn’t work for 2 unkowns :

    connection.query("update table set col1=? where col2=?",[val1],[val2],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});

The error message says “undefined is not a function”. What am i doing wrong?