Forum Moderators: open
I'm a bit of a newbie to mysql and wondered if you could help me with an unexpected parsing level I can't get my head round. The code I'm using to retrieve data from my database where a field called past is
<?php
$past = mysql_query("SELECT * FROM stories WHERE past="yes" ORDER BY ID DESC LIMIT 10;",$db);
while($row = mysql_fetch_row($past))
{
echo("<h1>" . $row[1] . "</h1>" . "</br>" . "<p>" . $row[3] . "<p>");
}
?>
The query runs fine through phpadmin but dies when I execute it does anybody have any advice you can offer
Cheers
JK
I believe the problem is on this line:
$past = mysql_query("SELECT * FROM stories WHERE past="yes" ORDER BY ID DESC LIMIT 10;",$db);
I assume what you want is entries where past is equal to the string "yes", right? If that's the case, then you want to surround it by single quotes, like this:
$past = mysql_query("SELECT * FROM stories WHERE past='yes' ORDER BY ID DESC LIMIT 10",$db);
Hope that does the trick for you...
Chad