1
$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();
}

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.