jayesch Posted April 3, 2006 Share Posted April 3, 2006 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><?phpheader("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 advanceJayesh Quote Link to comment Share on other sites More sharing options...
earl_dc10 Posted April 3, 2006 Share Posted April 3, 2006 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 Link to comment Share on other sites More sharing options...
jayesch Posted April 4, 2006 Author Share Posted April 4, 2006 [!--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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.