David
I'm sometimes, after refreshing seeing: "Supplied argument is not a valid MySQL result resource" on my homepage. I use random featured products.
I suspect my problem is in this code where "name" should be "normalised_name":
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$sqlIn.") GROUP BY name";
Does my proposed amendment sound correct to you?
What is normalised_name ?
(BTW My index.php came with my template from David Fiske)
John
Thanks David - looks like that's done the trick!
SQL was failing when products had imperial dimensions in product name; 6' x 4' garden sheds for example.
Cheers
John
Hi John,
Featured Products normally SELECTs by `name` - have a look to see if you have the following line a few lines above the line you posted:
$sqlNames[] = "'".$featured["name"]."'";
...and if so - REPLACE that with:
$sqlNames[] = "'".database_safe($featured["name"])."'";
The database_safe() part was missing from an early version of the random Featured Products mod that I posted, and would mean that if one of the randomly selected product names contained characters that would break the SQL the code would fail - which explains why you're only seeing the problem on some page views.
If you're not sure of course, email me your index.php and I'll check it out for you...
Cheers,
David.