I got a Syntax error:
You have an error in your SQL syntax, check the manual that corresponds to your
MySQL server version for the right sybtax to use near :data at line 1.
errno: 1064
SqlState: '42000'
This is The code to insert into the database:
function addCategory(category){
var execution = q.defer();
var query = 'INSERT INTO categories SET :data';
console.log(query);
connection.query(query,{data:category}, function(err, res){
if(err){
execution.reject(err);
console.log(err);
return;
}
execution.resolve(res);
});
return execution.promise;
}
While this function will get a category as a json object. the weird thing is that this function worked before and it was written the same way as the one giving the error.
Any ideas?