Jump to content


Photo

Problem with ImageCreate


  • Please log in to reply
2 replies to this topic

#1 jayesch

jayesch
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 03 April 2006 - 07:19 AM

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

#2 earl_dc10

earl_dc10
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 03 April 2006 - 11:36 PM

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
got a problem? Google helps many of those in need

#3 jayesch

jayesch
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 04 April 2006 - 04:48 AM

[!--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) View Post[/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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users