Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001071

[PHP-DB] A very simple MySQL + PHP error From: Brad Lipovsky (syzme <email protected>)
Date: 07/08/01

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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>