Why can't I output a picture
Session_Start ();
Number of random codes
$_rnd_code = 4;
Create Random Code
for ($i =0; $i <4; $i + +) {
$_nmsg.=dechex (Mt_rand (0,15));
}
Save session
$_session[' Code ']=$_nmsg;
Long and high
$_width = 75;
$_height = 25;
Create an image
$_img = Imagecreatetruecolor ($_width,$_height);
Output image
Header (' content-type:image/png ');
Imagepng ($_IMG);
The output result is
Notice: Undefined variable: _rnd_code inD:\AMP\web\ide_tmp.phpOn line -
Warning: Division by zero inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _heght inD:\AMP\web\ide_tmp.phpOn line -
Warning: Mt_rand (): Max (0) is smaller than min (1) inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _rnd_code inD:\AMP\web\ide_tmp.phpOn line -
Warning: Division by zero inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _heght inD:\AMP\web\ide_tmp.phpOn line -
Warning: Mt_rand (): Max (0) is smaller than min (1) inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _rnd_code inD:\AMP\web\ide_tmp.phpOn line -
Warning: Division by zero inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _heght inD:\AMP\web\ide_tmp.phpOn line -
Warning: Mt_rand (): Max (0) is smaller than min (1) inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _rnd_code inD:\AMP\web\ide_tmp.phpOn line -
Warning: Division by zero inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _heght inD:\AMP\web\ide_tmp.phpOn line -
Warning: Mt_rand (): Max (0) is smaller than min (1) inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _rnd_code inD:\AMP\web\ide_tmp.phpOn line -
Warning: Division by zero inD:\AMP\web\ide_tmp.phpOn line -
Notice: Undefined variable: _heght inD:\AMP\web\ide_tmp.phpOn line -
Warning: Mt_rand (): Max (0) is smaller than min (1) inD:\AMP\web\ide_tmp.phpOn line -
‰png
Modify by error message
Then you have to:
Still unfriendly "captcha" picture
Comment out the header and open the error to see the error.