PHP Notice: Undefined index: categoryFilter in /var/www/html/searchresults.php on line 57, referer: {link saved}
hmm looking at the code i can't see nothing wrong:
$sql1 = "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND category <> '' ORDER BY category";
if (database_querySelect($sql1,$rows1))
{
print "<label form='cf'>By category:</label><br />";
print "<select style='width:150px;' id='cf' name='categoryFilter'>";
print "<option value=''>All</option>";
foreach($rows1 as $row)
{
$selected = ($_GET["categoryFilter"]==$row["category"]?"selected='selected'":"");
print "<option value='".htmlentities($row["category"],ENT_QUOTES,$config_charset)."' ".$selected.">".$row["category"]."</option>";
}
Cheers for taking a look. I just noticed this in the apache error log, not sure if it's a common bug with the side bar mod?
Ah cheers david.
Also for others getting the same error. The merchant and brand filters need to be sorted out. Same procedure:
Replace:
$selected = ($_GET["merchantFilter"]==$row["merchant"]?"selected='selected'":"");
With:
if (isset($_GET["merchantFilter"]))
{
$selected = ($_GET["merchantFilter"]==$row["merchant"]?"selected='selected'":"");
}
else
{
$selected = "";
}
And replace:
$selected = ($_GET["brandFilter"]==$row["brand"]?"selected='selected'":"");
With:
if (isset($_GET["brandFilter"]))
{
$selected = ($_GET["brandFilter"]==$row["brand"]?"selected='selected'":"");
}
else
{
$selected = "";
}
Also in search.php the variables need to be changed so that they are checked that the filters are set.
$merchantFilter = (isset($_GET["merchantFilter"])?$_GET["merchantFilter"]:"");
$categoryFilter = (isset($_GET["categoryFilter"])?$_GET["categoryFilter"]:"");
$brandFilter = (isset($_GET["brandFilter"])?$_GET["brandFilter"]:"");
This eradicated the errors in my apache log.
Cheers for pointing me in the right direction david.
No probs, Steve - all above mods look good.
Cheers,
David.
--
PriceTapestry.com
Hi Steve,
The warning will be referring to this line:
$selected = ($_GET["categoryFilter"]==$row["category"]?"selected='selected'":"");
...to avoid undefined errors, REPLACE the above with:
if (isset($_GET["categoryFilter"]))
{
$selected = ($_GET["categoryFilter"]==$row["category"]?"selected='selected'":"");
}
else
{
$selected = "";
}
Cheers,
David.
--
PriceTapestry.com