I trying to update some info in MYSQL DB, but I'm not sure of how to do it with in node.js. This is the mysql driver I'm using https://github.com/felixge/node-mysql
What I have so far
connection.query('SELECT * FROM users WHERE UserID = ?', [userId], function(err, results) {
if (results[0]) {
if (results[0].Name!=name) {
console.log(results[0].Name);
connection.query('UPDATE users SET ? WHERE UserID = ?', [userId], {Name: name});
}
console.log(results[0].UserID);
}
});
Everything works except...
connection.query('UPDATE users SET ? WHERE UserID = ?', [userId], {Name: name});
In PHP I would have this...
mysql_query("UPDATE users SET Name='".$_GET["name"]."' WHERE UserID='".$row['UserID']."'");
I'm not sure what I'm doing wrong, But I'm positive that the issue is here
connection.query('UPDATE users SET ? WHERE UserID = ?', [userId], {Name: name});