Create verification code, suddenly a large number of anomalies, please help to see, thank you

Source: Internet
Author: User
Create a verification code, suddenly a lot of errors, please help to see, thank you

I'm trying to write a PHP script with a verification code, I start by suggesting that the image function is not available, so I added the PHP5-GD
After the installation is complete, the discovery or the tip cannot find the function
So I used Sudo/etc/init.d/apache2 focus-reload.
Then prompts for a function problem, but displays a large number of warning messages
I viewed the Modify php.ini file Error.report =e_all & ~e_notice
Restart the server but still,
The code is generated 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 yourself, the definition and use of constants are inconsistent
------Solution--------------------
It's obvious that 23 lines of your division inside the denominator cannot be zero because there are errors upside down $img variables have miscellaneous values so that 27 rows of imagesetpixel function do not have a usable picture 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.