I am running the following script here at home on PHP 4.1.2 and it runs smoothly; when I up load the script to the server I am getting a foreach error on the $imgList under PHP 4.2.3
function to grab the images from directory
function getImgList($dir)
{
global $thumbFlag;
$handle = opendir($dir);
while ($file = readdir($handle))
{
$ext = substr($file, strrpos($file, ".") + 1);
if (eregi('^(jpg|gif|png|jpeg|jpe)$', $ext) && !ereg("($thumbFlag\.$ext)$", $file))
$imgList[] = $file;
}
closedir( $handle );
if (!empty($imgList))
{
ksort($imgList);
return $imgList;
}
else
{
return False;
}
}
function to draw the table to build the thumbnails table which also has the foreach error
function thumbTable( $thumbRowCnt, $imgSpacing, $borderWidth, $borderColor )
{
global $thumbFlag, $gallery, $glocation, $imgList, $imgCnt;
if (!empty($borderWidth))
{
$bStr1 = "<table cellspacing=\"" . $imgSpacing . "\" cellpadding=\"" . $borderWidth . "\" border=\"0\"><tr><td bgcolor=\"#" . $borderColor . "\">";
$bStr2 = "</td></tr></table>";
$imgSpacing = "0";
}
else
{
$bStr1 = ""; $bStr2 = "";
}
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
$i = 1;
$count = 1;
foreach ($imgList as $img)
{
$thumbURL = "$glocation" . ereg_replace("\.", "$thumbFlag.", $img);
if ($i == 1)
{
echo "<tr>\n";
}
echo "<td>" . $bStr1;
echo "<a onmouseover=\"window.status='CLICK TO DISPLAY LARGER PICTURE'; return true\" href=\"javascript:imgSubmit('?gallery=" . $gallery . "&imgNo=" . $count . "&imgCnt=" . $imgCnt . "');\">";
echo "<img src=\"http://img.ebonyd.com" . $thumbURL . "\" border=\"0\" vspace=\"" . $imgSpacing . "\" hspace=\"" . $imgSpacing . "\"></a>";
echo $bStr2 . "</td>\n";
if ($i == $thumbRowCnt)
{
echo "\n</tr>\n";
$i = 1;
}
else
{
$i++;
}
$count++;
}
echo "</table>\n";
}