[code] 
<?php 
 session_start(); 
 for($i=0;$i<4;$i++){ 
  $rand.=dechex(rand(1,15)); 
 }  
 $_SESSION[check_pic]=$rand; 
 $im=imagecreatetruecolor(100,30); //设置验证码框的宽和高 
 $im=imagecolorallocate($im,0,0,0);//第一次调色背景颜色 
 $te=imagecolorallocate($im,255,255,255);//文字的颜色 
 imagestring($im,5,0,0,$rand,$te); 
  
?> [/code] 
提示错误 
Warning: imagecolorallocate(): supplied argument is not a valid Image resource in F:\AppServ\www\news\code.php on line 9 Warning: imagestring(): supplied argument is not a valid Image resource in F:\AppServ\www\news\code.php on line 10 
php.ini-recommended 
php.ini-dist 这两个文件的;extension=php_gd2.dll    ;这个符号我都去掉了。。 
我也重启了。但是还是出现错误。 

解决方案 »

  1.   

    这个如果是手动安装的话,可能会把几个.dll  COPY到windows文件夹下的,现在那就看你使用的哪个配置文件了。
      

  2.   

    你是修改的 Apache2\bin这个文件夹下的php.ini吗 试试这个
      

  3.   

    你说这个文件没有这个php.ini 文件啊!
      

  4.   

    (1)把php_gd2.dll这个文件复制到c:\windows\system32里;
    (2)找到php.ini 文件   把 ;extension=php_gd2.dll改为 extension=php_gd2.dll或者装个wamp吧
      

  5.   

    php.ini 就在你安装的PHP文件夹下面
      

  6.   

    (1)把php_gd2.dll这个文件复制到c:\windows\system32里;
    (2)找到php.ini 文件 把 ;extension=php_gd2.dll改为 extension=php_gd2.dll你说的方法我也做了不好使啊<?php
     session_start();
     for($i=0;$i<4;$i++){
      $rand.=dechex(rand(1,15));
     } 
     $_SESSION[check_pic]=$rand;
     $im=imagecreatetruecolor(100,30); //设置验证码框的宽和高
     $im=imagecolorallocate($im,0,0,0);//第一次调色背景颜色
     $te=imagecolorallocate($im,255,255,255);//文字的颜色
     imagestring($im,5,0,0,$rand,$te);
     
    ?>  
    这个是代码
      

  7.   


    <?
    session_start();
    //生成验证码图片
    Header("Content-type: image/PNG");
    $im = imagecreate(44,18);
    $back = ImageColorAllocate($im, 245,245,245);
    imagefill($im,0,0,$back); //背景
    srand((double)microtime()*1000000);
    //生成4位数字
    for($i=0;$i<4;$i++){
    $font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255));
    $authnum=rand(1,9);
    $vcodes.=$authnum;
    imagestring($im, 5, 2+$i*10, 1, $authnum, $font);
    }//for($i=0;$i<100;$i++) //加入干扰象素
    //{ 
    //$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    //imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
    //} ImagePNG($im);
    ImageDestroy($im);
    $_SESSION['VCODE'] = $vcodes;
    ?>