abhilashm86
December 11th, 2009, 03:35 PM
i'm building a contact form along with captcha, i'm getting this error on execution? why is it so?
can anyone try this and tell me what is wrong? is there any alternative to this?
<?php
session_start();
$string = '';
for ($i = 0; $i < 5; $i++) {
$string .= chr(rand(97, 122));
}
$_SESSION['rand_code'] = $string;
$dir = 'fonts/';
$image = imagecreatetruecolor(170, 60); //here is error??
$black = imagecolorallocate($image, 0, 0, 0);
$color = imagecolorallocate($image, 200, 100, 90);
$white = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image,0,0,399,99,$white);
imagettftext ($image, 30, 0, 10, 40, $color, $dir."arial.ttf", $_SESSION['rand_code']);
header("Content-type: image/png");
imagepng($image);
?>
error given from php,
Fatal error: Call to undefined function imagecreatetruecolor() in /var/www/captcha.php on line 16
also is there any difference between echo and print statements in php?
can anyone try this and tell me what is wrong? is there any alternative to this?
<?php
session_start();
$string = '';
for ($i = 0; $i < 5; $i++) {
$string .= chr(rand(97, 122));
}
$_SESSION['rand_code'] = $string;
$dir = 'fonts/';
$image = imagecreatetruecolor(170, 60); //here is error??
$black = imagecolorallocate($image, 0, 0, 0);
$color = imagecolorallocate($image, 200, 100, 90);
$white = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image,0,0,399,99,$white);
imagettftext ($image, 30, 0, 10, 40, $color, $dir."arial.ttf", $_SESSION['rand_code']);
header("Content-type: image/png");
imagepng($image);
?>
error given from php,
Fatal error: Call to undefined function imagecreatetruecolor() in /var/www/captcha.php on line 16
also is there any difference between echo and print statements in php?