Greetings to all,
I have a problem displaying an image on the Web. My environment is PHP 5.2.8, 64-bit Operating System. Windows Server Standard SP1 and is using php5isapi.dll: ISAPI v4.0.
<?php
//require 'config.php';
$image = imagecreate(200, 110);
$bg = imagecolorallocate($image, 225, 0, 0);
$color = imagecolorallocate($image, 255, 255, 255);
imageline($image,10, 10, 60, 60, $color);
header("Content-type: image/png");
imagepng($image);
?>
config.php is a standard php file in the same directory.
<?php
$myvar1='some value';
?>
The problem is if I require(require_once, include) config.php at the beginning of the script(see the red colored line above), the browser gives me the error "The image “http://www.myserver.com/DrawALine.php” cannot be displayed, because it contains errors.". If I comment this line out or move it to the end of the script, the image shows up.
I understand that header must be sent to browser before anything else, even a space character. I double checked to make sure there is no spaces in the script before header("Content-type: image/png");
When I copied the same code to a 32-bit windows machine. It worked.
As far as I can tell, the only difference between my 2 test machines is one is 32-bit and the other is 64-bit.
Can somebody here shed some light on it?
Any suggestions will be greatly appreciated,