RE: [PHP] select statement with variables ???
| From: | Jay Blanchard | Date: | Wed, 21 Dec 2005 13:33:11 +0000 |
| Subject: | RE: [PHP] select statement with variables ??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-227770@lists.php.net to get a copy of this message | ||
[snip]
> $query=" SELECT title FROM $cat WHERE id='$id'";
[/snip]
echo $query; // does it look right to you?
Alway throw an error when in question
if(!($result = mysql_query($query, $connection))){
echo mysql_error() . "<br>\n";
exit();
}
My bet is that you need to concatenate
$query = "SELECT title FROM " . $cat . " WHERE id = '". $id ."'
";