Im trying to use insert function and Im getting all the time an error :( Im trying to insert into user table a name of the user
My function:
function insert(tableName, toField, value){
connection.connect();
var queryString = "insert into "
+connection.escape(tableName)+" ("+connection.escape(toField)+")
select " + connection.escape(value)+"";
connection.query(queryString, function(err) {
if (err) throw err;
});
}
and in the main code:
insert("user", "name", "Anna");
Everytime I get an error:
Uncaught exception: 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 ''user' ('name') select 'Anna'' at line 1
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 ''user' ('name') select 'Anna'' at line 1
via Anna K
No comments:
Post a Comment