1

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 }

0

1 Answer 1

1

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){
Sign up to request clarification or add additional context in comments.

2 Comments

Good find, but its an insert statement actually. Still incorrect
@Shaharyar INSERT ... SET is a valid syntax in MySQL. It's not standard ANSI, but it's perfectly fine for MySQL.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.