Page 1 of 1

MySQL Error

Posted: Tue Mar 09, 2010 8:11 pm
by chizeng
Hello everyone,

I am receiving this error while developing a PhP/MySQL application:

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 ''id', 'pointkey', 'ptop', 'pleft', 'pOrder', 'mapKey', 'userName', 'title', 'des' at line 1

Here's the full query:

Code: Select all

mysql_query("INSERT INTO points ('id', 'pointkey', 'ptop', 'pleft', 'pOrder', 'mapKey', 'userName', 'title', 'description', 'more') VALUES (NULL ,  '$gKey',  '',  '',  '',  '$mapKey',  '$userName',  'New Point',  '','');") or die(mysql_error());
The $-signed variables I am pretty clear that I have already set. Any kind help from board members would be greatly appreciated. Thanks,


Chi

Re: MySQL Error

Posted: Tue Mar 09, 2010 8:41 pm
by w1n78
don't use single quotes when listing columns

Code: Select all

 
mysql_query("INSERT INTO points (id, pointkey, ptop, pleft, pOrder, mapKey, userName, title, description, more) VALUES (NULL ,  '$gKey',  '',  '',  '',  '$mapKey',  '$userName',  'New Point',  '','');") or die(mysql_error());
 

Re: MySQL Error

Posted: Tue Mar 16, 2010 5:15 pm
by chizeng
Thanks!

Re: MySQL Error

Posted: Tue Mar 16, 2010 7:27 pm
by flying_circus
w1n78 wrote:don't use single quotes when listing columns

Code: Select all

 
mysql_query("INSERT INTO points (id, pointkey, ptop, pleft, pOrder, mapKey, userName, title, description, more) VALUES (NULL ,  '$gKey',  '',  '',  '',  '$mapKey',  '$userName',  'New Point',  '','');") or die(mysql_error());
 
You should use back-ticks ( ` ) instead. :)

Code: Select all

 
mysql_query("INSERT INTO `points` (`id`, `pointkey`, `ptop`, `pleft`, `pOrder`, `mapKey`, `userName`, `title`, `description`, `more`) VALUES (NULL ,  '$gKey',  '',  '',  '',  '$mapKey',  '$userName',  'New Point',  '','');") or die(mysql_error());