Re: Simple search engine gone bad
| From: | David Robley | Date: | Tue, 30 Apr 2002 10:40:15 +0000 |
| Subject: | Re: Simple search engine gone bad | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18896@lists.php.net to get a copy of this message | ||
In article <20020430013309.51981.qmail@pb1.pair.com>, jendowney@attbi.com
says...
> Hi all,
>
> It's Monday, it's probably something stupid, but I have poured over this all
> day and cannot find the problem.
> This is a simple search engine based on one table. It is suppose to return
> the results of the search word. Instead it returns ALL records in the mysql
> table. If I type the letter x and there are no words in the table with an x
> I still get all records returned.
>
> Would someone be kind enough to show me what I have done wrong.
>
>
> if($search)
> {
> $query = "SELECT iname, quantity, user, price FROM
> {$config["prefix"]}_shop WHERE iname LIKE '%$searchword%' AND price > 0
> ORDER BY price";
> $ret = mysql_query($query) or die(mysql_error());
> while($row = mysql_fetch_array($ret))
> {
Try echoing your $query to make sure that you are in fact passing an
expected vlue for $searchword. If, for whatever reason, $searchword is
empty you will get all records in the table whose value is >0
You seem to be a newcomer to programming. Any time you have a problem, it
its always useful to echo the arguments that might have a bearing on the
result you are expecting.
--
David Robley
Temporary Kiwi!
Quod subigo farinam