Encountered a Syntax error:
You have an error in your SQL syntax, please refer to the manual corresponding to your
MySQL server version for the correct syntax to use near :data at line 1.
errno: 1064
SqlState: '42000'
This is The code used for database insertion:
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;
}
This function expects a category as a JSON object. Interestingly, this function worked previously and was implemented similarly to the one causing the error.
Any insights on how to resolve this issue?