Error using SQL with javascript

Asked

Viewed 32 times

0

I would like to know what is wrong with those lines, especially in the query, as it is not working:

pool.query('SELECT * FROM `info` WHERE `id` = 1', function(err, row1) {
    var jogo = row1[0].jogo;
    var numerojogadores = row1[0].numerojogadores;
    // Se o numero de jogadores for 2 ou mais começa...
    if (numerojogadores > 1) {
        // Inicio do Contador
        socket.broadcast.emit('count', count);
        count--;
        console.log(count);
        // Fim do Contador
    }
    if (count === 0) {
        var novojogo = "jogo2";
        pool.query('UPDATE info SET jogo = novojogo WHERE id = 1', function(err) {
            console.log(err);
            count = 60;
        });
    }
});
  • What’s wrong with you?

  • Unknow column '1'

  • Won’t this error be another query? Tests run this UPDATE directly in mysql, gives the same error?

  • 'UPDATE info SET jogo = novojogo WHERE id = 1'?

  • Directly in mysql works, I will leave my code all.

  • I put all the code.

  • If you replace var with a number, it already works. Does anyone know any way to put vars?

  • Dude I think this problem is related to the backticks you put in. Which is the line that gives the error?

  • I already realized, I would have to put it this way: '+var+'

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.