Forums
This topic is locked
sql error
Posted 10 Jul 2006 19:18:38
1
has voted
10 Jul 2006 19:18:38 Mark Reynolds posted:
Can someone pls let me know what is wrong with this<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>"SELECT * FROM match_users WHERE iam ='%s' AND meet = '%s' AND for = '%s' AND zipcode LIKE '%%%s%%' AND online = '%s'"<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
When i run that query it throws an error....
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>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 'for = '-1' AND zipcode LIKE '%%' AND online = 'yes' LIMIT 0, 10' at line 1<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I think is has something to do with the table name <b>for </b>because when i remove that part it runs fine
Any guidance appreciated
Thanks
Mark
Mark Reynolds
Replies
Replied 11 Jul 2006 11:23:00
11 Jul 2006 11:23:00 Patrick Woldberg replied:
FOR is a reserved word in MySQL, you can solve it by quoting it with backticks, change the query to:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>"SELECT * FROM match_users WHERE iam ='%s' AND meet = '%s' AND `for` = '%s' AND zipcode LIKE '%%%s%%' AND online = '%s'"<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>"SELECT * FROM match_users WHERE iam ='%s' AND meet = '%s' AND `for` = '%s' AND zipcode LIKE '%%%s%%' AND online = '%s'"<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------