PDA

View Full Version : Unsupported operand types (php)



pucca
October 22nd, 2006, 12:22 PM
I've got a HUGE prob!! Got a script for resizing images php. I got the following error message :
Fatal error: Unsupported operand types in /v.www/htdocs/destinationafrica.org/includes/misc_functions.php on line 109


Heres m code:


$size = getimagesize('old/spimages/' . $rowspic["imee"]);
$height = $size;
$width = $size;
if ($width > 450)
{
$width = 450;
$percent = ($size / $width);
$height = ($size / $percent);
}
echo '<td rowspan="2"><img src="old/spimages/' . $rowspic['imee'] . '" height="' . $height . '" width="' . $width . '" /></td>';


Line nr. 109 is the
$percent = ($size / $width); one.

PLEASE help! Have NO idea what this means, and can't fins any answers on the web... Thanks in advance!

bigmtnskier
October 22nd, 2006, 12:46 PM
You forgot to add "[0]" and "[1]" after $size when you specify $width and $height. So, you are essentially setting $width and $height both equal to the array that contains both of them: Array ( [0] => 800, [1] => 600 ).

PHP is just telling you that you can't see if an array is greater than 400. So, use this:



$size = getimagesize('old/spimages/' . $rowspic["imee"]);
$height = $size[1];
$width = $size[0];
if ($width > 450)
{
$width = 450;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
echo '<td rowspan="2"><img src="old/spimages/' . $rowspic['imee'] . '" height="' . $height . '" width="' . $width . '" /></td>';


-bigmtnskier :)

pucca
October 22nd, 2006, 01:14 PM
Thanks! the images looks perfect now, but I get another error message:
Warning: getimagesize() [function.getimagesize]: Read error! in /v.www/htdocs/destinationafrica.org/includes/misc_functions.php on line 103 ??? WHY? isn't that a common php function?

pucca
October 22nd, 2006, 01:22 PM
HA! Fixed. WOW!!! thanks alot!!! You only need to put a @ infront of the function :


$size = @getimagesize('old/spimages/' . $rowspic["imee"]);

Never new THAT??!!!! thanks alot!

McGuffin
October 22nd, 2006, 01:23 PM
Putting the @ symbol in front of PHP functions only suppresses the error messages from showing. It doesn't solve the error, just stops it from showing ;)

pucca
October 22nd, 2006, 01:43 PM
o???.. so, will it still be a problem? Cause my images are showing perfectly.. will it be a problem?:hurt: