Problem with the word ADD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smartrah
Forum Newbie
Posts: 1
Joined: Mon Nov 30, 2009 7:35 am

Problem with the word ADD

Post by smartrah »

I am having trouble creating a table with the name 'ADD' as a user submits this word in a php form. Any other user entry into the form works fine in creating a table.

Here is the error line "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 'add (Name VARCHAR(30), Day INT(3), Month VARCHAR(15), Year INT(5), Shift VARCHAR' at line 1"

Why only this error with the word 'ADD'


Help Please!
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Problem with the word ADD

Post by jackpf »

Try using backticks (`) around the table name. Add is probably a reserved word.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Problem with the word ADD

Post by AbraCadaver »

ADD is a reserved word. You'll need to quote it to use it.

-Shawn
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Problem with the word ADD

Post by jackpf »

Yeah, cause that isn't exactly what I just said -_-
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Problem with the word ADD

Post by AbraCadaver »

Doh! I had this window open, went out for a smoke, came back and answered it.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Problem with the word ADD

Post by jackpf »

haha

Ahh well, nice to know someone agrees with me ;p

...you were out for 22 mins?! Wonder what you were smoking...
Post Reply