PDA

View Full Version : [php] getimagesize() error



Thinker2501
January 26th, 2005, 04:42 PM
I am using getimagesize and retrieving the file name from an array. In the MySQL database the column the file names are stored in is set to TinyText. I'm using the following code to create the HTML tag for the images:

<?php
if ($result_ar['picfile'] == "") {
echo "<img src=\"images/listings/noimage.jpg\" width=\"100\" height=\"100\">";
} else {
$imagesize = getimagesize("images/listings/"+$result_ar['picfile']); echo "<img src=\"images/listings/"; echo $result_ar['picfile']; echo "\""; echo $imagesize[3]; echo ">";
}
?>

When I go to the page the images are all rendered correctly, but the following error code appears above each one:

Warning: getimagesize(88): failed to open stream: No such file or directory in /home/grubbsf/public_html/index.php on line 122

The "88" is the only the first part of the file name stored in the array. In this case the full name is "88kearny.jpg". Why is it giving that error and still rendering the images correctly? How do I fix it? Thanks in advance.

terlan
January 26th, 2005, 10:54 PM
Not totally sure about this but the code that says


getimagesize("images/listings/"+$result_ar['picfile']);

should read

getimagesize("images/listings/".$result_ar['picfile']);

using + instead of . is adding the 88 (the only numeric part of the file name) to the "images/listings/" part (which it is reading as 0) and causing your error.

This might not be all thats causing it but it might help.