tags:

views:

362

answers:

3
$c = $record['corrects'];
$i = $record['incorrects'];

if($c == 0 && $i == 0)
{
 $image = imagecreatetruecolor(200,80);

 $white = imagecolorallocate($image,255,255,255);
 $red = imagecolorallocate($image,255,0,0);

 imagefilledrectangle($image,0,0,199,79,$white);

 $text = 'Quiz cancelled!';

 $box = imageftbbox(10,0,'verdana.ttf',$text);

 $x = imagesx($image)/2 - abs($box[2] - $box[0])/2 - 5;

 $y = imagesy($image)/2 - abs($box[5] - $box[3])/2 - 5;

 imagefttext($image,10,0,$x,$y,$red,'verdana.ttf',$text);

 header('Content-type: image/png');

 imagepng($image);
 imagedestroy($image);

 exit();
}
A: 

I tried it, and it works. It produced a piece of red text, saying "Quiz canceled!".

Maybe you should check whether $c and $i are both indeed 0?

I assume you have < ? php and ? > tags at the beginning and end of the file?

Edit: also, is the ttf font file in the right location?

It might help also if you could give a bit more information: is the browser giving an error? Or just not showing anything?

Ben

Ben
+1  A: 

Comment out the imagepng() and header() calls and view the output in your browser to see if any errors are being generated

Paul Dixon
no avail! :( nothing shows
anjan
A: 

As has been said, the question's a bit sketchy on details.

Is the GDFONTPATH environment variable set correctly?

<?php
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));

(from uk.php.net/imagefttext)

David Heggie