ReVeR Posted March 18, 2006 Share Posted March 18, 2006 Hello.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:[code]$ad=ImageCreateFromJPEG($field); Header('Content-type: image/jpeg'); ImageJPEG($ad);[/code]where filed points to an image on the hd.i get the following error:[code]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[/code]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?Thx Quote Link to comment https://forums.phpfreaks.com/topic/5248-headers/ Share on other sites More sharing options...
hitman6003 Posted March 18, 2006 Share Posted March 18, 2006 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:[code]<h1>some html</h1><br /><img src="image.php" alt="this is an image dynamically generated by php">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5248-headers/#findComment-18631 Share on other sites More sharing options...
ReVeR Posted March 18, 2006 Author Share Posted March 18, 2006 ah dam...alrite, i will go back to that:Pthx alot. Quote Link to comment https://forums.phpfreaks.com/topic/5248-headers/#findComment-18635 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.