PDA

View Full Version : query is returning 0 results when there should be results


Paul Ferrie
06-24-2005, 06:00 PM
Hi guys,

Very strange i thought i had this working earlier.

I tested this in phpmyadmin and it worked fine.


//Would be sent from flash, used for testing
$theID="(letID=4)+(letID=60)+(letID=61)+(letID=3)+(letID=5 )+(letID=6)";
$query = "SELECT * FROM scLets WHERE '$theID'";
$result = mysql_query($query);
if (!$result) {
fail("Couldn't list Lets from database");
}
$letCount = mysql_num_rows($result);


$letCount returns 0

But if i do it this way

$query = "SELECT * FROM scLets WHERE (letID=4)+(letID=60)+(letID=61)+ (letID=3)+(letID=5)+(letID=6)";
$result = mysql_query($query);
if (!$result) {
fail("Couldn't list Lets from database");
}
$letCount = mysql_num_rows($result);


It works fine :S

I need to be able to build the letID list.

Anyone.

Cheers

splict
06-24-2005, 06:05 PM
the difference between the two is the ' signs around the $theID variable in the first one.
$query = "SELECT * FROM scLets WHERE '$theID'";
// should be
$query = "SELECT * FROM scLets WHERE $theID";
// maybe?

Paul Ferrie
06-24-2005, 06:30 PM
God give me some credit :P
Do u not think i would have tried that before typing this post out.

No it didn't work

"Fail couldn't list results from database"

CyanBlue
06-24-2005, 06:33 PM
How about...
$query = "SELECT * FROM scLets WHERE " . $theID;