Thread: SQL Syntax Error on edit submit
08-16-06, 12:23 #1Registered User
- Join Date
- Mar 2003
Unanswered: SQL Syntax Error on edit submit
hi i am lost!!! really lost, i have some php script that i am trying to slightly change by adding a new text entry field.
I have made the change and get the following error when i click my submit button.
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 '&bname='450', price=NULL, special_price='Simply immaculate detac
`b&bname` varchar(50) default NULL, `id` int(11) NOT NULL auto_increment, `cid` int(11) default NULL, `scid` int(11) default NULL, `mid` int(11) default NULL, `title` varchar(50) default NULL, `price` double default NULL, `special_price` double default NULL, `pdate` datetime default NULL, `sold` varchar(4) default NULL, `description` text, `address` varchar(50) default NULL, `city` varchar(45) default NULL, `state` varchar(45) default NULL, `zip` varchar(50) default NULL, `exp` int(11) default NULL, `featured` varchar(4) default NULL, `active` varchar(5) default NULL, `hits` int(11) default NULL, `bed` varchar(10) default NULL, `bath` varchar(10) default NULL, `subdiv` varchar(60) default NULL, `schoold` varchar(60) default NULL, `year` int(11) default NULL, `lot_size` double default NULL, `sqft` double default NULL, `lat` varchar(40) default NULL, `long` varchar(40) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
It is an edit.php (renamed to file.txt for uploading purposes) file, so i am trying to edit a current record in my mysql table.
the new field i have added is called "b&bname"
I have added a new field in mymsql table called "b&bname"
i really don't get why i am getting this error.
my full code is attached :
08-16-06, 12:43 #2Registered User
- Join Date
- Apr 2006
- Denver, Co. USA
Because the "&" symbol has special meaning it should not be used in variable names... In this case, mysql let you create the column name with it, but in order to be able to use this in a query, you must enclose it in back-ticks ` - `b&bname`=%s
To avoid this problem (I see other names in your code using the & symbol) and produce code that will work under the widest possible conditions, you should only use letters, numbers, and an under-score in identifier names.
Edit: From the mysql manual -If an identifier is a reserved word or contains special characters, you must quote it whenever you refer to it. ... Special characters are those outside the set of alphanumeric characters from the current character set, ‘_’, and ‘$’.
The identifier quote character is the backtick (‘`’):
Last edited by dbmab; 08-16-06 at 12:49.