Why can't I output an image?

Source: Internet
Author: User
Why can't I output a picture session_start (); // number of random codes // $ _ rnd_code & nbsp ;=& nbsp; 4; // create random codes for ($ I = 0; $ I & lt; 4; $ I ++) {$ _ nmsg. = dechex (mt_rand ();} // Save the session. Why can't I output an image?
Session_start ();

// Number of random codes
// $ _ Rnd_code = 4;

// Create a random code
For ($ I = 0; $ I <4; $ I ++ ){
$ _ Nmsg. = dechex (mt_rand (0, 15 ));
}

// Save the session
$ _ SESSION ['code'] =$ _ nmsg;

// Length and height
$ _ Width = 75;
$ _ Height = 25;

// Create an image
$ _ Img = imagecreatetruecolor ($ _ width, $ _ height );



// Output image
Header ('content-Type: image/png ');
Imagepng ($ _ img );

The output result is
------ Solution --------------------
 
Notice:  Undefined variable: _rnd_code in D:\AMP\web\ide_tmp.php on line 53

Warning:  Division by zero in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _heght in D:\AMP\web\ide_tmp.php on line 53

Warning:  mt_rand(): max(0) is smaller than min(1) in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _rnd_code in D:\AMP\web\ide_tmp.php on line 53

Warning:  Division by zero in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _heght in D:\AMP\web\ide_tmp.php on line 53

Warning:  mt_rand(): max(0) is smaller than min(1) in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _rnd_code in D:\AMP\web\ide_tmp.php on line 53

Warning:  Division by zero in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _heght in D:\AMP\web\ide_tmp.php on line 53

Warning:  mt_rand(): max(0) is smaller than min(1) in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _rnd_code in D:\AMP\web\ide_tmp.php on line 53

Warning:  Division by zero in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _heght in D:\AMP\web\ide_tmp.php on line 53

Warning:  mt_rand(): max(0) is smaller than min(1) in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _rnd_code in D:\AMP\web\ide_tmp.php on line 53

Warning:  Division by zero in D:\AMP\web\ide_tmp.php on line 53

Notice:  Undefined variable: _heght in D:\AMP\web\ide_tmp.php on line 53

Warning:  mt_rand(): max(0) is smaller than min(1) in D:\AMP\web\ide_tmp.php on line 53
‰PNG
Modify by error message
Then you need:
Still unfriendly "verification code" image

------ Solution --------------------
Comment out the header and open the error to see the error.

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.