php variable problem
<p>I have the following php code, which has been snipped for brevity. I am having trouble with the code after $lastImg is declared, specifically size never seems to get assigned any value, and the hence outputwidth and outputheight remain blank. I have been unable to spot the cause of this.</p>

<p>pic_url is just a string in the database, and definitely points to a valid image. When I run my page without the code to resize, the image is displayed perfectly.</p>

<pre><code>&lt;?php
header("Content-Type: text/html; charset=utf-8");

if (isset($_GET["cmd"]))
    $cmd = $_GET["cmd"];
else
    die("You should have a 'cmd' parameter in your URL");

$pk = $_GET["pk"];
$con = mysql_connect("localhost", "someuser", "notreal");

if(!$con)
{
    die('Connection failed because of' . mysql_error());
}

mysql_query('SET NAMES utf8'); 
mysql_select_db("somedb",$con);

if($cmd == "GetAuctionData")
{
    $sql="SELECT * FROM AUCTIONS WHERE ARTICLE_NO ='$pk'";
    $sql2="SELECT ARTICLE_DESC FROM AUCTIONS WHERE ARTICLE_NO ='$pk'";
    $htmlset = mysql_query($sql2);
    $row2 = mysql_fetch_array($htmlset);

    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result))
    {
     $columns = array('FINISHED', 'WATCH', 'PRIVATE_AUCTION', 'REVISED', 'PAYPAL_ACCEPT', 'PRE_TERMINATED', 'PIC_XXL', 'PIC_DIASHOW');
     foreach($columns as $column)
     {
      $$column = $row[$column] ? 'YES' : 'NO';
     }

     $lastImg = $row['PIC_URL']; 
     $maxWidth  = 250;
     $maxHeight = 300;

         $size = getimagesize($_SERVER['DOCUMENT_ROOT'] . $lastImg);
var_dump($size);
echo "SIZE = ".$size."";
if ($size) {
    $imageWidth  = $size[0];
    $imageHeight = $size[1];
    $wRatio = $imageWidth / $maxWidth;
    $hRatio = $imageHeight / $maxHeight;
    $maxRatio = max($wRatio, $hRatio);
else {
die(print_r(error_get_last())); }
else if ($maxRatio &gt; 1) {
        $outputWidth = $imageWidth / $maxRatio;
        $outputHeight = $imageHeight / $maxRatio;
    } else {
        $outputWidth = $imageWidth;
        $outputHeight = $imageHeight;
    }
}

     echo "&lt;h1&gt;".$row['ARTICLE_NAME']."&lt;/h1&gt;
      &lt;div id='rightlayer'&gt;
      &lt;img src='".$lastImg."' width='".$outputWidth."' height='".$outputHeight."'&gt;
      &lt;/div&gt;";
    }
}

mysql_free_result($result);
</code></pre>
