Jump to content



  • Please log in to reply
2 replies to this topic

#1 ReVeR

  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 18 March 2006 - 08:04 PM

I have a set up of using 2 php files for the top part of the web site and another file for bottom part.
Now, in the bottom part i wanted to generate an image with php so i have the following code:
            Header('Content-type: image/jpeg');
where filed points to an image on the hd.
i get the following error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache Group\Apache2\htdocs\web_business_2\header.php:44) in C:\Apache Group\Apache2\htdocs\web_business_2\lower.php on line 155
I know i am sending headers in the header.php (top part of the web), but why can;t i send them from the bototm part too? note that both of these 2 parts are included in test.php which basicly uses the header and the lowert php to defined the web site and then puts its own code in between.

Any ideas how to bypass teh error?

#2 hitman6003

  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 18 March 2006 - 08:19 PM

You can not send both regular text/html headers and image headers for the same document. It can either be a webpage, or an image, not both.

The reason you get the headers already sent message is because some output has already been sent to the browser...if your code is at the bottom of your page, that makes sense.

If you are wanting to generate an image in php, then display it back as a part of a webpage, you need to use an img tag in your html, then for the src attribute, use your php image page:

<h1>some html</h1><br />
<img src="image.php" alt="this is an image dynamically generated by php">

#3 ReVeR

  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 18 March 2006 - 08:23 PM

ah dam...alrite, i will go back to that:P
thx alot.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users