<?php
// Set up the image.
$height = 200;
$width = 200;
$im = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$blue = imagecolorallocate($im, 0, 0, 64);
// Draw on the Image.
imagefill($im, 0, 0, $blue);
imageline($im, 0, 0, $width, $height, $white);
imagestring($im, 4, 50, 150, 'Sales', $white);
// Output image
Header ('Content-type: image/png');
imagepng ($im);
// Clean up
imagedestroy($im);
?>
<?php
// I have tried to put the header here and it did not work.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
// I have also tried to put the header here and it did not work.
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<title>Generating Images</title>
<link rel="stylesheet" type="text/css" href="" />
<script type="text/javascript" src=""></script>
</head>
<body>
<div id="header">
</div>
<div id="container">
<div id="content">
<?php
// Set up the image.
$height = 200;
$width = 200;
$im = imagecreatetruecolor($width, $height);
$white = imageColorAllocate($im, 255, 255, 255);
$blue = imageColorAllocate($im, 0, 0, 64);
// Draw on the Image.
imagefill($im, 0, 0, $blue);
imageline($im, 0, 0, $width, $height, $white);
imagestring($im, 4, 50, 150, 'Sales', $white);
// Output image
Header ('Content-type: image/png'); // The header I have tried in other locations at top of page
imagepng ($im);
// Clean up
imagedestroy($im);
?>
</div>
<div id="navCol">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
$imgfile = getcwd() . 'my.png';
imagepng ($im, $imgfile);
echo "<img src=\"my.png" />\n";
Do you get any output? Are there any messages in your PHP error log?