You need to put the ob_start() call at the very beginning of your script, 
not inside that function. You have to turn output buffering on before ANY 
output is generated, if you want to be able to send headers later on.

miguel

On Fri, 24 May 2002, Gerard Samuel wrote:
> Im trying to use dynamic buttons, and Im trying to figure out how to get 
> around the header call.
> I figure use output buffering, but so far Ive only come up with errors.
> Anyone see a better way or any errors in my code.
> Thanks
> 
> nb:  Uncomment the echo() statement to get the error.
> --------------------------------------------------
> <?php
> 
> //echo 'Hey<br>';
> 
> function button($word) {
>     ob_start();
>     header("Content-Type: image/png");
>     $im = ImageCreate(100, 50);
> 
>     $black = ImageColorAllocate($im, 0, 0, 0);
>     $white = ImageColorAllocate($im, 255, 255, 255);
> 
>     $start_x = 50 - (strlen($word) * ImageFontWidth(5) / 2);
>     $start_y = 25 - ImageFontHeight(5) / 2;
> 
>     ImageString($im, 5, $start_x, $start_y, $word, $white);
> 
>     ImagePNG($im);
>     ImageDestroy($im);
>     ob_end_flush();
> }
> 
> button('Hello World');
> 
> ?>
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to