PHP Help

Discussion in 'PHP' started by Pudge1, Sep 3, 2009.

  1. #1
    
    <?php
    if(file_exists('/home/nintendo/public_html/picblur/' . $_POST['file'] . '.png'))
    {
    }
    else
    {
    echo "Picture Does Not Exist!";
    }
    
    $im = imagecreatefrompng('/home/nintendo/public_html/picblur/' . $_POST['file'] . '.png');
    $currentheight = 1;
    $currentwidth = 1;
    $size = getimagesize('/home/nintendo/public_html/picblur/' . $_POST['file'] . '.png');
    $width = $size[0];
    $height = $size[1];
    
    while($done !== 'yes')
    {
    $rgb = imagecolorat($im, $currentheight, $currentwidth);
    $r = ($rgb >> 16) & 0xFF;
    $g = ($rgb >> 8) & 0xFF;
    $b = $rgb & 0xFF;
    
    $r = 255 - $r;
    $g = 255 - $g;
    $b = 255 - $b;
    
    $color = imagecolorallocate($im,$r,$g,$b);
    
    imagefilledrectangle($im,$currentwidth,$currentheight,$currentwidth,$currentheight,$color);
    $currentwidth++;
    
     if($currentwidth < $width)
     {
     }
     else
     {
      if($currentheight <= $height)
      {
      }
      elseif($currentwidth = $width)
      {
      $currentheight++;
      $currentwidth = '1';
      }
      else
      {
      $done = 'yes';
      }
     }
    }
    
    header('Image/PNG');
    imagepng($im);
    imagedestroy($im);
    ?>
    
    Code (markup):
    Why does that return a 500 error?
     
    Pudge1, Sep 3, 2009 IP
  2. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Perahaps it's because the file does not exist? You test for it but the script still proceeds if it fails the test. Change it to read:
    
    
    <?php
    if(file_exists('/home/nintendo/public_html/picblur/' . $_POST['file'] . '.png'))
    {
    
    $im = imagecreatefrompng('/home/nintendo/public_html/picblur/' . $_POST['file'] . '.png');
    $currentheight = 1;
    $currentwidth = 1;
    $size = getimagesize('/home/nintendo/public_html/picblur/' . $_POST['file'] . '.png');
    $width = $size[0];
    $height = $size[1];
    
    while($done !== 'yes')
    {
    $rgb = imagecolorat($im, $currentheight, $currentwidth);
    $r = ($rgb >> 16) & 0xFF;
    $g = ($rgb >> 8) & 0xFF;
    $b = $rgb & 0xFF;
    
    $r = 255 - $r;
    $g = 255 - $g;
    $b = 255 - $b;
    
    $color = imagecolorallocate($im,$r,$g,$b);
    
    imagefilledrectangle($im,$currentwidth,$currentheight,$currentwidth,$currentheight,$color);
    $currentwidth++;
    
     if($currentwidth < $width)
     {
     }
     else
     {
      if($currentheight <= $height)
      {
      }
      elseif($currentwidth = $width)
      {
      $currentheight++;
      $currentwidth = '1';
      }
      else
      {
      $done = 'yes';
      }
     }
    }
    
    header('Image/PNG');
    imagepng($im);
    imagedestroy($im);
    
    }
    else
    {
    echo "Picture Does Not Exist!";
    }
    
    ?>
    
    
    PHP:
     
    superdav42, Sep 3, 2009 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    What is the chmod settings of the directory "picblur"
     
    Bohra, Sep 3, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You don't need to tell us that it returns a "500 error", you need to show the error logs.
     
    premiumscripts, Sep 3, 2009 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    Nevermind it was just the header. I set it wrong.
     
    Pudge1, Sep 4, 2009 IP
  6. yuvrajm

    yuvrajm Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Once even I had a similar problem, and same way, changing the header did the job
     
    yuvrajm, Sep 4, 2009 IP