vdkuipb
vdkuipb

Reputation: 13

Node js insert Mysql doesnt work

this is part of the code i use

var insertedData = {
        name: 'testname',
        score: '1337'
    };
connect.query('INSERT INTO table SET ?', insertedData, function(error, result){

and this is the error i got

{ [Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table SET name = 'Hek', score = '12'' at line 1]code: 'ER_PARSE_ERROR', errno: 1064, sqlState: '42000',index: 0 }

Upvotes: 1

Views: 322

Answers (1)

Mureinik
Mureinik

Reputation: 311018

table is a reserved word in MySQL. I'd advise to rename your table to something else. If this is absolutely not a possibility for you, you can escape it with backticks:

connect.query('INSERT INTO `table` SET ?', insertedData, function(error, result){

Upvotes: 1

Related Questions