javascript - Change password with mysql query in node.js? -


i tried change password of user id: 273 tried , not working. planning on using manage database on node.js

this code:

var mysql = require('mysql'); var connection = mysql.createconnection({     host: '127.0.0.1',     user: 'root',     password: 'root',     database: 'kitsune',     //connectionlimit: 50,     port: 3306 });  connection.connect(function(err) {     if (err) throw err; });  const iduser = 273; // id const newpassword = "dfgfgsd22";  // change password uppercased md5 var insertquery = "update `penguins` set `password` = upper(md5('" + newpassword + "') id = " + iduser + ";"  connection.query(insertquery, function(error, results, fields) {;     console.log(insertquery);     console.log(json.stringify(results));   if (error) throw error; }); module.exports = connection; connection.end(); // end connection 

it should update password user id 273 in md5 uppercase, keep getting following error:

error: er_parse_error: have error in sql syntax; check manual corresponds mariadb server version right syntax use near 'where id = 273' @ line 1

the query gets printed out:

update penguins set password = upper(md5('dfgfgsd22') id = 273;

you have written

var insertquery = "update `penguins` set `password` = upper(md5('" + newpassword + "') id = " + iduser + ";" 

here

`password` = upper(md5('" + newpassword + "') 

now 1 bracket closing

`password` = upper(md5('" + newpassword + "')) 

replace following line

  var insertquery = "update `penguins` set `password` = upper(md5('" + newpassword + "')) id = " + iduser + ";" 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -