PCHomepage
Programmer
This was working but suddenly it isn't and I see nothing changed. I have verified the search form is submitting and it is setting the session from which the search is made. It is getting to the final ELSE, then giving this error five times when searching on a single keyword:
so it is clear that somehow the explode() or sizeof() are misfiring but, as I've not changed anything, I cannot discover what's wrong. Can anyone spot what I've missed?
(I did it as a session so that the appropriate words can be highlighted once one selects and views the details page from the search results.)
Notice: Undefined offset: 2 in C:\Sites\sitename\functions\site_search.php on line 224
so it is clear that somehow the explode() or sizeof() are misfiring but, as I've not changed anything, I cannot discover what's wrong. Can anyone spot what I've missed?
(I did it as a session so that the appropriate words can be highlighted once one selects and views the details page from the search results.)
Code:
if (isset($_SESSION['KeyString'])) :
$ReplaceValues = array("\'"," the ","The ");
$KeyString = trim($_SESSION['KeyString']);
$KeyString = str_replace($ReplaceValues, "", $KeyString);
$tok = explode(" ", $KeyString);
$size = sizeof($tok);
for ($i = 0; $i < $size; $i++);
if (($i == 0) && ($i == $size-1)) :
$Where .= " AND (rt.Title LIKE '%".$tok[$i]."%' OR Description LIKE '%".$tok[$i]."%' OR History LIKE '%".$tok[$i]."%' OR KeyWords LIKE '%".$tok[$i]."%' OR KeyWords LIKE '%".$tok[$i]."%' OR CatalogNo LIKE '%".$tok[$i]."%' OR r.ID LIKE '%".$tok[$i]."%')";
elseif ($i == 0) :
$Where .= " AND ((rt.Title LIKE '%".$tok[$i]."%' OR Description LIKE '%".$tok[$i]."%' OR History LIKE '%".$tok[$i]."%' OR KeyWords LIKE '%".$tok[$i]."%' OR CatalogNo LIKE '%".$tok[$i]."%' OR r.ID LIKE '%".$tok[$i]."%')";
elseif ($i == $size-1) :
$Where .= " AND (rt.Title LIKE '%".$tok[$i]."%' OR Description LIKE '%".$tok[$i]."%' OR History LIKE '%".$tok[$i]."%' OR KeyWords LIKE '%".$tok[$i]."%' OR CatalogNo LIKE '%".$tok[$i]."%' OR r.ID LIKE '%".$tok[$i]."%'))";
else :
$Where .= " AND (rt.Title LIKE '%".$tok[$i]."%' OR Description LIKE '%".$tok[$i]."%' OR History LIKE '%".$tok[$i]."%' OR KeyWords LIKE '%".$tok[$i]."%' OR CatalogNo LIKE '%".$tok[$i]."%' OR r.ID LIKE '%".$tok[$i]."%')";
endif;
endif;