I have a database for my classified ads for our club. I have the structure as follows:
adEmail varchar(35) Yes
Now, I have a query to insert into this database, but it fails and I cannot figure out why.
query to insert:
INSERT INTO Classified ('Name', 'Address1', 'City', 'State', 'ZipCode', 'adEmail', 'PhoneNumber', 'Member', 'AdType', 'Ad_Content', 'Date_Submitted', 'Duration', 'Active') VALUES ('richerd', '9876', here', 'WA', '99217', 'email@example.com', '508-555-1212', '0', 'Wanted', ' wanting something', '04-16-2012', '3', 1)
Data did not get inserted into Participant table - 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 ''Name', 'Address1', 'City', 'State', 'ZipCode', 'adEmail', 'PhoneNumber', 'Membe' at line 1
Please let me know what I am doing wrong.
Oh, PHP version is 5.2.17 just in case you were going to ask...
the relevant syntax is
INSERT INTO tablename ( [I]list of columns[/I] ) VALUES ( [I]list of values[/I] )
instead of a list of columns, you have a list of strings
mysql's backtick, the spawn of the devil, pwns yet another developer!!
Ah, yes. Used the wrong "marker".
However, begs the question, are the backticks really needed? And, why does phpmyadmin put them in? Just to confuse us that learn by "example"??
Thanks and it is now working.
phpmyadmin puts them in because you didn't turn that option off
backticks are not needed if you remember never to put a special character (like a space or number sign) into a table or column name, or use a reserved word (like order) for a table or column name
This topic is now archived. It is frozen and cannot be changed in any way.