I've been looking into using mysql inside node js lately and I've stumbled upon a problem that I can't figure out.
I have a form in my index.html that sends an registeruser socket to the server with an array called data. I use this to put everything in my query(almost everything). But for some reason it doesn't work.
I have also tried to use connection.escape() but this didn't solve the problem.
Could someone please look into this? Thank you! Me
client.on('RegisterUser', function(data){
data[2] = sha1(data[2]);
var registerarray = data;
var hashkey = sha1(registerarray[0]) + Date.now();
connection.query("INSERT INTO user_information SET 'username'=" + registerarray[1] + ", 'password'=" + registerarray[2] + ", 'name'=" + registerarray[0] + ", 'email'=" + registerarray[3] + ", 'gender'=" + registerarray[4] + ", 'birthday'=" + registerarray[5] + ", 'country'=" + registerarray[6] + ", 'regdat'=" + Date.now() + ", 'hashkey'=" + hashkey + ", 'online'=1", function(err, results){
if (err){console.error(err);
}else{console.log("success".green);}
});
});
via Axel D'Olislager
No comments:
Post a Comment