生成验证码问题

生成验证码问题

别人的代码是好好的,可是在我的机子上一运行,就出现警告对话框:就是无法下载之类的鬼话.php.ini里extension=php_gd2.dll,也加载了,到底是怎么加速呢?

提示什么啊?最好发代码出来
如履薄冰

代码是

[复制到剪切板]
CODE:
<?
Header("Content-type: image/PNG");  
srand((double)microtime()*1000000); 
$im imagecreate(62,20); 
$black ImageColorAllocate($im0,0,0); 
$white ImageColorAllocate($im255,255,255); 
$gray ImageColorAllocate($im200,200,200); 
imagefill($im,68,30,$gray); 
while((
$authnum=rand()%100000)<10000);
//将四位整数验证码绘入图片 
imagestring($im5103$authnum$black); 
for(
$i=0;$i<200;$i++)   //加入干扰象素 

    
$randcolor ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    
imagesetpixel($imrand()%70 rand()%30 $randcolor); 

ImagePNG($im); 
ImageDestroy($im); 
?> ;


出现错误提示信息如下
文件下载
您想打开或保存此文件吗.

[ 本帖最后由 yafeikf 于 2008-3-3 23:29 编辑 ]

你改成这样试试

[复制到剪切板]
CODE:
<?
Header("Content-type: image/PNG");  
srand((double)microtime() * 1000000); 
$im imagecreate(62,20); 
$black ImageColorAllocate($im0,0,0); 
$white ImageColorAllocate($im255,255,255); 
$gray ImageColorAllocate($im200,200,200); 
imagefill($im,68,30,$gray); 
while((
$authnum=rand()%100000)<10000);
//将四位整数验证码绘入图片 
imagestring($im5103$authnum$black); 
for(
$i=0;$i<200;$i++)   //加入干扰象素 

    
$randcolor ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    
imagesetpixel($imrand()%70 rand()%30 $randcolor); 

ImagePNG($im); 
ImageDestroy($im); 
?> ;


我的Blog

程序有点问题
while(($authnum=rand()%100000)<10000);
是个死循环

[复制到剪切板]
CODE:
<?
Header("Content-type: image/PNG");  
srand((double)microtime()*1000000); 
$im imagecreate(62,20); 
$black ImageColorAllocate($im0,0,0); 
$white ImageColorAllocate($im255,255,255); 
$gray ImageColorAllocate($im200,200,200); 
imagefill($im,68,30,$gray); 
$authnum=rand(1000,9999);
//将四位整数验证码绘入图片 
imagestring($im5103$authnum$black); 
for(
$i=0;$i<200;$i++)   //加入干扰象素 

    
$randcolor ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    
imagesetpixel($imrand()%70 rand()%30 $randcolor); 

ImagePNG($im); 
ImageDestroy($im); 
?> ;


提示下载说明已经输出图片了。我本机测试无问题
想显示出来也可以用这样的方式,比如说生成图片的是im.php
可以另见一个文件里面<img src="im.php">显示出来
如履薄冰

还是不行呀,一预览,就会打开 :Adobe ImageReady CS