Help me execute this php code. It won't executes

Discussion in 'PHP' started by 11alex11, Mar 29, 2010.

  1. #1
    I have this code to add watermark. I tried to run it on my iis7 server but the only thing I get on the screen is the full path of the php script

    why is that?
     
    11alex11, Mar 29, 2010 IP
  2. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    put your script text here.
     
    stOK, Mar 29, 2010 IP
  3. 11alex11

    11alex11 Peon

    Messages:
    113
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php 
    
    header('content-type: image/jpeg');  
    
    $watermark = imagecreatefrompng('watermark.png');  
    $watermark_width = imagesx($watermark);  
    $watermark_height = imagesy($watermark);  
    $image = imagecreatetruecolor($watermark_width, $watermark_height);  
    $image = imagecreatefromjpeg($_GET['wallpapers/Black_Dog.jpg']);  
    $size = getimagesize($_GET['wallpapers/Black_Dog.jpg']);  
    $dest_x = $size[0] - $watermark_width - 5;  
    $dest_y = $size[1] - $watermark_height - 5;  
    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);  
    imagejpeg($image);  
    imagedestroy($image);  
    imagedestroy($watermark);  
    
    ?>
    Code (markup):
    the watermark picture and the wallpapers folder located in the same place where the script is.
     
    11alex11, Mar 29, 2010 IP
  4. Nyu

    Nyu Peon

    Messages:
    79
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Comment out the header() function and you'll see the errors your script throws ;)
     
    Nyu, Mar 29, 2010 IP
  5. 11alex11

    11alex11 Peon

    Messages:
    113
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    it displays blank page no errors
     
    11alex11, Mar 29, 2010 IP
  6. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #6
    From a quick look what is the $_GET in the imagecrate and getimagesize in there for?
    You would use get for a variable in the URL since you already have the value of the variable (wallpapers/Black_Dog.jpg) you can place that directly in the tags
    try:
    
    <?php 
    
    header('content-type: image/jpeg');  
    
    $watermark = imagecreatefrompng('watermark.png');  
    $watermark_width = imagesx($watermark);  
    $watermark_height = imagesy($watermark);  
    $image = imagecreatetruecolor($watermark_width, $watermark_height);  
    $image = imagecreatefromjpeg('wallpapers/Black_Dog.jpg');  
    $size = getimagesize('wallpapers/Black_Dog.jpg');  
    $dest_x = $size[0] - $watermark_width - 5;  
    $dest_y = $size[1] - $watermark_height - 5;  
    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);  
    imagejpeg($image);  
    imagedestroy($image);  
    imagedestroy($watermark);  
    
    ?>
    
    PHP:
     
    Narrator, Mar 29, 2010 IP
  7. 11alex11

    11alex11 Peon

    Messages:
    113
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks that solved the problem.
    How can I debug php or any other web code?
     
    11alex11, Mar 29, 2010 IP
  8. peoplesmind

    peoplesmind Active Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #8
    On a linux box, /var/log/httpd usually holds the error_log, from which you can view errors generated by PHP. On a localhost WAMP/EasyPHP/etc, you can find a similar file depending on your setup. It's extremely useful.
     
    peoplesmind, Mar 29, 2010 IP
  9. 11alex11

    11alex11 Peon

    Messages:
    113
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I found the logs but when I try to open them it says that it already in use. How can I see the logs? maybe with the iis manager?
     
    11alex11, Mar 30, 2010 IP