Jump to content

Archived

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

croakingtoad

problem w/ php mysql syntax

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?

Share this post


Link to post
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());

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.