socket.on('query', function(data) {
db.query('SELECT email FROM players WHERE email=?', [email], (err,result) => {
if(err) console.log(err);
result = JSON.stringify(result[0]);
if(result != undefined) result = 'yes';
if(result == undefined) result = 'no';
console.log(result);
if(result == 'yes') {
socket.emit('warning');
}
if(result == 'no') {
db.query("INSERT INTO players (nickname,email) VALUES('" + nick + "','" + email + "')", (err,result) => {
if(err) console.log(err);
console.log("Insert");
});
}
});
});
Оно работает всегда