A very simple MySQL + PHP error
| From: | Brad Lipovsky | Date: | Sun, 08 Jul 2001 18:26:14 +0000 |
| Subject: | A very simple MySQL + PHP error | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-10150@lists.php.net to get a copy of this message | ||
I get the following error:
//error
Warning: Supplied argument is not a valid MySQL result resource in
/web/sites/184/syzme/www.syzme.f2s.com/Commerce_System/search.php on line 22
//error
when I try to use this code:
<?php
$Link = mysql_connect ($Host, $User, $Password);
//code
if ($category) {
$Query = "SELECT * from $TableName WHERE ((category)=$category)";
} else { if ($title) {
$Query = "SELECT * from $TableName WHERE title LIKE "%$title%")";
}
}
$Result = mysql_db_query ($DBName, $Query, $Link);
print "Your search query of <b> $category </b> returned the following
results:<br><br>";
while ($Row = mysql_fetch_array ($Result)) {
print "<a href=item.php?p=$Row[id]>";
echo ( $Row[title] );
print "</a><br>";
}
mysql_close ($Link);
?>
//code
on my site. If i pass in a value for $category, it works fine... the error
arises when I try to pass in a value for $title. I want it to search a
MySQL DB for anything with the string $title in it, and then print it out in
the while structure. Thanks
Brad