I have a page that grabs relative URLs to images from a MySQL 4.1.7 database (only up to six at a time). The images that these urls point to are generally <30kb each.
The results look like this:
./Folder/imagename.jpg
Then, a while loop runs through the results, uses the location to find the image and runs a resize function, and displays the results.
Here is the while loop:
// CHECK FOR ANY IMAGES
$imageQuery = "SELECT * FROM skylark_listings_images WHERE image_prod_id=\"$id\" LIMIT 6";
$imageResult = $DBC->Execute($imageQuery);
$i = 1;
while ($imageRow = $imageResult->FetchRow()) {
$Image_Array = Image_Tool($imageRow['image_loc']);
echo"
<td class=\"EditPanelCell\" width=\"150\" height=\"150\" align=\"center\">
<table width=\"150\" height=\"123\">
<tr>
<td align=\"center\">
<img
src=\"" . $imageRow['image_loc'] . "\"
border=\"0\"
height=\"" . $Image_Array[1] . "\"
width=\"" . $Image_Array[0] . "\">
</td>
</tr>
<tr>
<td align=\"center\">
<span class=\"panelFormFieldLabels\">
" . $Image_Array[2] . " - " . $imageRow['image_size'] . "
</span>
</td>
</tr>
<tr>
<td align=\"center\">
<a href=\"\" class=\"panelFormFieldLabels\">
[remove]
</a>
</td>
</tr>
</table>
</td>";
}
Here is the function:
function Image_Tool($Use_Image){
$Src_Img_Size = getimagesize("$Use_Image");
$width=$Src_Img_Size[0];
$height=$Src_Img_Size[1];
if($height>="$width"){
$x=100*($width/$height);
$Scale_Width=$x;
$Scale_Height=100;
} else {
$x=100*($height/$width);
$Scale_Width=100;
$Scale_Height=$x;
}
switch($Src_Img_Size[2]){
case 1:
$image_type = "gif";
break;
case 2:
$image_type = "jpg";
break;
case 3:
$image_type = "png";
break;
case 4:
$image_type = "swf";
break;
case 5:
$image_type = "psd";
break;
case 6:
$image_type = "bmp";
break;
case 7:
$image_type = "tif";
break;
}
$Image_Array=array(
"$Scale_Width",
"$Scale_Height",
"$image_type");
return $Image_Array;
}
PROBLEM: If I have more than two image URLs returned with the query (thus more than two image URLs passed through the function Image_Tool) then the script fails and stops processing the rest of the PHP code. In Firefox and Opera it shows the whole page to that point - IE 6 just says "page cannot be displayed".
I verfied that the ADOdb connection works fine. If I remove all the HTML from the above while loop, and just echo anything by itself (i.e. the location, or an array) then everything works (displays) fine. Otherwise, the script dies.
I am using PHP 5.0.2 on Windows XP, Apache 2.0.52.