Jump to content

problem w/ php mysql syntax


croakingtoad

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/10454-problem-w-php-mysql-syntax/
Share on other sites

$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());
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]
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 query

What's strange is when I type the query into SQLyog--

SELECT * FROM flex_residential WHERE mls = 701555

it 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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.