See, I am using the following PHP code to generate a PNG image file
<?php
// create a 100*30 image
$im = imagecreate(100, 30);
// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// write the string at the top left
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);
// output the image
header("Content-type: image/png");
imagepng($im);
?>
The above code works absolutely fine if I am running on the top of my webpage,
But if I try to run anywhere in between my page, then it generates the following error
The image "http://localhost" cannot be displayed, because it contains erros
I know this is due to because I am passing the header after the HTML codes, but if I try to pass the header before any HTML tag then I get the same error as above.
Any suggestions?
PS: I want to make a graphical counter at the bottom of my page, and this is the reason I need this code to work. Or is there any alternative????
Kindly Help
God Bless