croakingtoad Posted May 25, 2006 Share Posted May 25, 2006 here's what I have-[code]$query = mysql_query("SELECT * FROM $table WHERE mls = $MLS") or die(mysql_error());[/code]I'm getting the error-[code]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 'WHERE mls = 701555' at line 1[/code]What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/ Share on other sites More sharing options...
bbaker Posted May 25, 2006 Share Posted May 25, 2006 $query = mysql_query("SELECT * FROM $table WHERE mls = [b][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--][/b] $MLS [b][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--][/b] ") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-38987 Share on other sites More sharing options...
croakingtoad Posted May 25, 2006 Author Share Posted May 25, 2006 I changed mine to match your suggestion but I still get the error--[code]$query = mysql_query("SELECT * FROM $table WHERE mls = '$MLS'") or die(mysql_error());[/code][code]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 'WHERE mls = '701555'' at line 1[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-38988 Share on other sites More sharing options...
.josh Posted May 25, 2006 Share Posted May 25, 2006 you sure mls is an integer type data type? Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-38990 Share on other sites More sharing options...
croakingtoad Posted May 25, 2006 Author Share Posted May 25, 2006 that's what it was, i had it as varchar Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-38992 Share on other sites More sharing options...
croakingtoad Posted May 26, 2006 Author Share Posted May 26, 2006 Okay, maybe not... I changed it in the DB from varchar to int and empties the DB then ran the script to put data back into it and I am still getting that error. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-39214 Share on other sites More sharing options...
AndyB Posted May 26, 2006 Share Posted May 26, 2006 [code]$query = mysql_query("SELECT * FROM $table WHERE mls = '$MLS'") or die("Error: ". mysql_error(). " with query ". $query);[/code]That way you can see the actual query being used that results in the error. Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-39216 Share on other sites More sharing options...
croakingtoad Posted May 26, 2006 Author Share Posted May 26, 2006 That didn't give much more info--Error: 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 'WHERE mls = '701555'' at line 1 with queryWhat's strange is when I type the query into SQLyog--SELECT * FROM flex_residential WHERE mls = 701555it returns the correct result...I'm such an idiot, nevermind. I wasn't passing a required variable to the url to satisfy a switch I had right above this code that gives the value of $table.Sorry for my Friday dumbness! Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-39219 Share on other sites More sharing options...
nogray Posted May 26, 2006 Share Posted May 26, 2006 Try to add the `` quotes around the table name and the mls like this[code]$query = mysql_query("SELECT * FROM `$table` WHERE `mls` = '$MLS'") or die("Error: ". mysql_error(). " with query ". $query);[/code]Sometimes this does the trick for me Quote Link to comment https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/#findComment-39226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.