Reputation: 243
I am trying to make a mysql insert like this one here
<http://www.w3schools.com/php/php_mysql_insert.asp >
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)
I am trying to insert the values below into the table userbase.
54007033331, Codi Y, Male, pub, http://google.com/ggg.jpg
INSERT INTO userbase (id,name,gender,publicity,pic) VALUES (54007033331, Codi Y, Male, pub, http://google.com/ggg.jpg)
MySQL query failed: 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 'Y, Male, pub, http://google.com/ggg.jpg)' at line 1
Can anyone please point me in the right direction of how to fix this syntax error?
Upvotes: 3
Views: 6856
Reputation:
You should quote properly string and char values in query.
INSERT INTO userbase (id,display,gender,publicity,pic)
VALUES (54007033331, 'Codi Y', 'Male', 'pub', 'http://google.com/ggg.jpg')
Upvotes: 8
Reputation: 2847
Without knowing your column types I can't be sure, but I would hazard a guess that the values for all bar the first column are strings and the values need to be quoted with single quotes:
INSERT INTO userbase (id,display,gender,publicity,pic)
VALUES (54007033331, 'Codi Y', 'Male', 'pub', 'http://google.com/ggg.jpg')
Though if you're doing this programmatically, you should be using placeholders:
INSERT INTO userbase (id,display,gender,publicity,pic)
VALUES (?, ?, ?, ?, ?)
and value binding.
Upvotes: 1