PHP query to mysql database returns emtpy data, but Query Browser shows records
| From: | Jason Walker | Date: | Thu, 06 Jan 2005 04:27:13 +0000 |
| Subject: | PHP query to mysql database returns emtpy data, but Query Browser shows records | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-37993@lists.php.net to get a copy of this message | ||
Here is the query:
function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
$comIB = $cat . " " . $pack . " " . $hotcat . " " .
$hotid;
$catLength = strlen($comIB);
echo $catLength;
$query = "SELECT description from cpProducts where category='" .
$cat . " " . $pack . " " . $hotcat . " " . $hotid .
"'";
echo "<bR>" . $query . "<br>";
echo "combined package number = " . $comIB . "<br>";
$retval = "";
$link =
mysql_connect($config['host'],$config['user'],$config['pass']) or
die("Could
not connect");
mysql_select_db('stc_store') or die("Unable to connect to the
default database");
$result = mysql_query($query) or die("Unable to pull the
menu objects for main event details");
echo mysql_affected_rows() . "<br>";
while ($results = mysql_fetch_array($result, MYSQL_ASSOC)){
extract($results);
echo $description;
$retval = $description;
}
mysql_free_result($result);
mysql_close($link);
return $retval;
}
I have some extra 'echo' statements to see the progress on the web page. If
I remove the 'where' clause within the SQL statement, I get rows. But when I
add the 'where' portion, no records are returned.
Here is an example of what the query looks like:
$query example = SELECT description from cpProducts where category='39 47 48
172'
When I run the same query in MYSQL Control center or Query Browser, no
problem. I use this function template for my SELECT statements.
Please let me know if there is something missing from the code.
Thanks.
Jason Walker
jwalker@desktophero.com
http://www.desktophero.com