Results 1 to 5 of 5

Thread: php5 problems

  1. #1
    Join Date
    May 2007
    Posts
    4

    Unanswered: php5 problems

    My host recently upgraded to php 5 and I have this code to display an image (with a random number in for spam protection). It worked on php4 but the image isn't working now (on php 5). Anybody know what it is?

    PHP Code:
    <?php
    session_start
    ();

    $image imagecreate(12030);

    $white    imagecolorallocate($image0xFF0xFF0xFF);
    $gray    imagecolorallocate($image0xC00xC00xC0);
    $darkgray imagecolorallocate($image0x500x500x50);

    srand((double)microtime()*1000000);

    for (
    $i 0$i 30$i++) {
      
    $x1 rand(0,120);
      
    $y1 rand(0,30);
      
    $x2 rand(0,120);
      
    $y2 rand(0,30);
      
    imageline($image$x1$y1$x2$y2 $gray);  
    }

    for (
    $i 0$i 5$i++) {
    $cnum[$i] = rand(0,9);
    }


    for (
    $i 0$i 5$i++) {
     
    $fnt rand(3,5);
     
    $x $x rand(12 20);
     
    $y rand(12); 
     
    imagestring($image$fnt$x$y$cnum[$i] , $darkgray); 
    }

    $digit "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";

    $_SESSION['digit'] = $digit;

    header('Content-type: image/png');
    imagepng($image);
    imagedestroy($image);
      
    ?>

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    have you included the same library that you used in your old PHP build in the new. looks like you may be usign the GD library.. is the version built as part of the PHP 5 Installation compatible?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    If i'm not mistaken the default installation of PHP 5 doesn't have error reporting turned on, which ultimately means you're not going to get any errors on output. Do a simple phpinfo() script and see if you have your GD library installed (as healdem suggested).

  4. #4
    Join Date
    May 2007
    Posts
    4
    thanks guys. i will have to ask my hosts about which GD they are using but GD is definately installed. error reporting seems to be on E_ALL as default. This one is truly baffling!

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    rather than rely on the config I'd try explicitly setting the warning level in the script that is failing, especially if you are having problems.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •