Answer the question
In order to leave comments, you need to log in
Why is mysql+node.js acting weird?
For some unknown reason, this code does not work in a bunch of node.js and mysql:
var sql = 'DELETE FROM `test` WHERE id = "'+results[0]['id']+'"';
connection.query(sql);
connection.query('SELECT * FROM `test` WHERE `hold` = "1" AND `status` = "0"', function(err, results) {
if (err) throw err;
if (results[0]['botStop'] == '1') {
clearInterval(interval);
console.log('stopped')
}
else {
var id = results[0]['id'];
var sql = 'DELETE FROM `test` WHERE id = "'+results[0]['id']+'"';
console.log(sql);
connection.query(sql);
console.log('trade '+id+' started');
}
});
Answer the question
In order to leave comments, you need to log in
Because there is no function in which the result of the query will be returned, can you tell me what is the result of DELETE? And I will answer you that this result is provided for connection.query and even DELETE can return an error, and if there is nowhere to return it, then the function call format is violated, it has every right not to work. Also, for the sake of Allah, don't glue SQL with strings.
var sql = 'DELETE FROM test WHERE id = ?';
connection.query(sql, [results[0]['id']], function (err) {
if (err) console.log('Error query');
});
Have you heard of injections?
It's hard to say why it doesn't work from such a small piece of code, without even knowing what library you used for the muscle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question