Jump to content

Archived

This topic is now archived and is closed to further replies.

jayesch

Problem with ImageCreate

Recommended Posts

I know I sound very stupid for writing this post. I have read probably 100 documents by this time. I am working on an assignment in my class for which I need to to poll a SNMP based device and show the input output traffic statistics in form a GIF image. I have never worked on PHP before. Although the portion of the script which collects the statistics from SNMP device is working correctly, the other part which deals with image creation doesnt work. So I tried to write a very basic program to create a GIF image.

<html>
<head>
<title> PHP TEST </title>
</head>
<body>
<?php
header("Content-type: image/gif");
$im = imagecreate(600,115);
$backgroundColor = imagecolorallocate($im,204,204,153);
imagefill($im,0,0,$backgroundColor);
imagegif($im);
?>
</body>
</html>



The problem is that it gives me warning :-

""Warning: Cannot modify header information - headers already sent by (output started at /home/compsci/jsharma/public_html/program3.php:6) in /home/compsci/jsharma/public_html/program3.php on line 8"

I know this problem is created because of white space character. But despite my sincere efforts I have not been able to locate any white spaces before or after <?php and ?> tags. Also instead of a GIF image I see some junk characters in the browser.

If i remove line containing header(); then the warning goes off but I still see junk characters in the browser and no image.

Please tell me if I am missing on something.

Thanks in advance
Jayesh

Share this post


Link to post
Share on other sites
remove your <html> <head> and <body> tags, only have your php script in the web page, trust me I had the same problem and this cleared it up

Share this post


Link to post
Share on other sites
[!--quoteo(post=361396:date=Apr 3 2006, 06:36 PM:name=earl_dc10)--][div class=\'quotetop\']QUOTE(earl_dc10 @ Apr 3 2006, 06:36 PM) [snapback]361396[/snapback][/div][div class=\'quotemain\'][!--quotec--]
remove your <html> <head> and <body> tags, only have your php script in the web page, trust me I had the same problem and this cleared it up
[/quote]


Thank you so much for your help. This is the wierd problem that no one mentions in the text books or online tutorials. While rest of your code works with HTML tags, this doesnt.

Jayesh

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.