A large number of exceptions suddenly occurred when you created the verification code. thank you for your help.

Source: Internet
Author: User
When I created a verification code, a large number of errors suddenly occurred. could you please help me? thank you for writing a php script for the verification code. I first started to prompt that the image function is unavailable, so I added the php5-gd after the installation is complete, and found that still tishi can not find the function so I used sudo & nbsp; etcinit. dapache2 & nbsp; focus-reload and then & nbsp; the system prompts function problems, but displays a large number of warning information. I checked the modification & nbs creation verification code and suddenly encountered a large number of errors. please take a look, thank you

I'm trying to write a php script for a verification code, first starting to prompt that the image function is unavailable, so I added a php5-gd
After the installation is complete, it is found that the function still cannot be found by Tieshi.
So I used sudo/etc/init. d/apache2 focus-reload.
Then a function problem is prompted, but a large amount of warning information is displayed.
I have checked and modified the php. ini file error. report = E_ALL &~ E_NOTICE
Restart the server,
The verification code is as follows:

session_start();
//set some important identfy constants
define('IDENTFY_NUM',5);
define('IDENTFY_WIDTH',75);
define('IDENTFY_HEIGT',25);
//create the random pass-phrase
$pass_phrase="";
for($i=0;$i $pass_phrase.=chr(rand(97,122));

}
$_SESSION['pass_phrase']=sha1($pass_phrase);
$img=imagecreatetruecolor(IDENTFY_WIDTH,IDENTFY_HEIGHT);
$bg_color=imagecolorallocate($img,255,255,255);
$text_color=imagecolorallocate($img,0,0,0);
$graphic_color=imagecolorallocate($img,64,64,64);

imagefilledrectangle($img,0,0,IDENTFY_WIDTH,IDENTFY_HEIGHT,$bg_color);

//Draw random lines
for($i=0;$i<5;$i++){
imageline($img,0,rand()%IDENTFY_HEIGHT,IDENTFY_WIDTH,rand()%INDENTFY_HEIGHT,$graphic_color);
}
for($i=0;$i<50;$i++){
imagesetpixel($img,rand()%IDENTFY_WIDTH,rand()%IDENTFY_HEIGHT,$graphic_color);

}
//Draw the string
imagettftext($img,18,0,5,IDENTFY-5,$text_color,"Courier New Bold.ttf",$pass_phrase);
header("Content-type:image/png");
imagepng($img);
imagedestroy($img);
?>


------ Solution --------------------
Check by yourself. The definition and usage of constants are inconsistent.
------ Solution --------------------
Obviously 23 rows have been prompted. the denominator in your division cannot be zero because there is an incorrect inversion here. $ the img variable contains miscellaneous values, so that the imagesetpixel function of 27 rows does not have an available image resource.

for($i=0;$i<5;$i++){
imageline($img,0,rand()%IDENTFY_HEIGHT,IDENTFY_WIDTH,rand()%INDENTFY_HEIGHT,$graphic_color);
}



for($i=0;$i<50;$i++){
imagesetpixel($img,rand()%IDENTFY_WIDTH,rand()%IDENTFY_HEIGHT,$graphic_color);

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.