What is the problem with this query?

0

Good, I have this query that I do with my API REST in NodeJS

router.get("/create/:id/:name/:img",function(req,res){
    var query = "INSERT INTO ??, (??, ??, ??) VALUES (?, ?, ?)";
    var table = ["demos", "id", "name", "img", req.params.id, req.params.name, req.params.img];
    query = mysql.format(query,table);
    connection.query(query,function(err,rows){
        if(err) {
            res.json(err);
        } else {
            res.json(rows);
        }
    });
});

And the problem is that it returns this error to me

{"code":"ER_PARSE_ERROR","errno":1064,"sqlState":"42000","index":0}

I can not find the problem, but ... sure one has a solution hehe, greetings.

    
asked by Santiago D'Antuoni 11.01.2017 в 22:49
source

1 answer

-1

Verify the comma your query should be as follows.

"INSERT INTO ?? (??, ??, ??) VALUES (?, ?, ?)";
    
answered by 11.01.2017 в 23:17