我用的php是4.3.8版本的 写了一个验证码的程序,为什么出现红叉??谁能帮忙解决一下???
Header("Content-type: image/PNG"); 
srand((double)microtime()*1000000);
$im = imagecreate(62,20);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,68,30,$gray);
while(($authnum=rand()%100000)<10000);
//将四位整数验证码绘入图片
imagestring($im, 5, 10, 3, $authnum, $black);
for($i=0;$i<200;$i++)   //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);  

解决方案 »

  1.   

    直接运行这个文件,会报错
    <br />
    <b>Fatal error</b>:  Call to undefined function:  imagecreate() in <b>/server/apache/htdocs/corp_tj_test/test.php</b> on line <b>30</b><br />
      

  2.   

    gd图库可能没开,
    解决办法:在php.ini中将;extension=php_gd2.dll前边的;去掉
    然后将php目录中的ext下的php_gd2.dll拷入c:\windows\system32,重启apache
      

  3.   

    我用的php版本是4.3.8版本的,没有找到php_gd2.dll这个文件啊
      

  4.   

    没找到php_gd2.dll,就到网上下一个么!
      

  5.   

    那如果是unix系统应该把这个文件放在哪里?
      

  6.   

    这是linux的gd安装步骤,希望对楼主有用
    http://bbs.365master.com/thread-156836-1-1.html