Hi David,
when I type into the search form of one of my sites ( {link saved} ) the word
brands
then the search is executed normally.
But when I type in
brand
then the result ends in the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/web117/html/reduced/includes/database.php on line 27
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/web117/html/reduced/includes/database.php on line 32
What can this cause?
Regards
Roland
Oh you sweet. I was getting error log of about 2MB a day with this error, up untill today, I was tearing my hair out to slove this problem. Finally, I got the solution. Applied the fix and for once over 3000 hits with no errors.
Thank Dave and Thanks Roland for brigning to Dave's attention.
Noor
Hi Dave,
Just realise same error happens if I type in "bw". I don't know what is "bw" in the search.php is, for some reason I am still getting same error not as much as it used to. I just wonder whether you have the similar fix for this. Applying the fix in the thread reduced my error log from 3MB/day to 2KB/day.
Also is there any way to banning all robots using .htaccess file (as bad robot generally do not respect robots.txt file) but allow few robots from likes of Google, Bing, Yahoo, Infospider etc..
Thanks for your help again :-)
Noor
Hello Noor,
Same reason - bw is the "begins with" operator (for example you could create an A-Z of all products on your site by linking to search results for bw:A, bw:B etc.) To fix this instance, look for the following code around line 164:
$where = "search_name LIKE '".database_safe($parts[1])."%'";
...and REPLACE with:
if (isset($parts[1]) && $parts[1])
{
$where = "search_name LIKE '".database_safe($parts[1])."%'";
}
else
{
$where = "0";
}
I'm afraid I don't believer there is a negative match option in the robots.txt specification. Most "bad robot" strategies I think involve .htaccess together with IP range / user-agent matching...
Cheers,
David.
--
PriceTapestry.com
Hi Roland,
The same will happen (on your site) with "category" and "merchant" as these are the search operators that are intended to prefix the merchant, category or brand being searched e.g.
brand:Brand Name:
What's happening is "brand" on its own is generating invalid SQL so I will correct this in the distribution; in the mean time, to correct this look in your search.php for the following code:
$first = FALSE;
}
(line 105 in 12/10B)
...and REPLACE with:
$first = FALSE;
}
if ($where=="") $where=" 0 ";
Cheers,
David.
--
PriceTapestry.com