Page 1 of 1

getimagesize/if statement problem

Posted: Thu Nov 01, 2007 10:10 am
by davidtube
I have the following code which is supposed to make an image fit inside a 250x250 table cell.

Code: Select all

$imageinfo = getimagesize("$imagelocation");
         
$ix=$imageinfo[0];
$iy=$imageinfo[1];

if (iy>ix)
{
$nheight=$iy/$iy*250;
$nwidth=$ix/$iy*250;
$test="y";
}
else
{
$nheight=$iy/$ix*250;
$nwidth=$ix/$ix*250;
$test="x";
}
		echo "' width='".$nwidth."' height='".$nheight."'/></a></center>". $ix.$iy.$test."
When $ix and $iy are echoed, the correct numbers are produced, but the if statement always produces the results as if $iy is greater. Am I missing something simple?

Posted: Thu Nov 01, 2007 10:13 am
by seppo0010
Am I missing something simple?
Really simple... you are not usign $ in the if =)

Code: Select all

if (iy>ix) 

// should be
if ($iy>$ix) 

// right now it works like
if ('iy'>'ix')

Posted: Thu Nov 01, 2007 11:35 am
by davidtube
:oops:
Thanks. It just need a fresh pair of eyes looking at it I suppose.