Re: A very simple MySQL + PHP error

From: Date: Sun, 08 Jul 2001 19:20:55 +0000
Subject: Re: A very simple MySQL + PHP error
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10151@lists.php.net to get a copy of this message
In my oppinion the error is in the Line: WHERE title LIKE "%$title%")"; because you have a ")" too much and write the search String a follow: WHERE title LIKE '%$title%'; important is the symbol ' not " . I hope this helps you. bye Hoth "Brad Lipovsky" <syzme@home.com> schrieb im Newsbeitrag news:20010708182828.84349.qmail@pb1.pair.com... > 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 > >

« previous php.db (#10151) next »