Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Warning: Cannot modify header information - headers already sent by 3

Status
Not open for further replies.

musa10

Technical User
Apr 7, 2005
26
US
Hello everyone,
My server harddrive crashed the other day and I replaced all my file with a backup I had so I got everything working. Ive also installed and configured the latest PHP with Apache.. So everything is working fine.. But when I go to my shoutbox page it gives me the following


Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php on line 18

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php on line 20

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\amember\hall\discussion\step 1\index.php on line 22


What does that mean? How can I fix this problem? Thanks!!
 
Line 18 of the index.php wants to send headers -- either redirect to another page or start session management or create a cookie (hard to tell when we cannot see the code) and it cannot, because there has already been output in line 5. Inspect what code wants to send headers and look for an output before that: print, echo statement, white-space above php block, plain html before html block...
 
Hello Vrag...
I found out the problem... This is my 1-22 lines. When I took out the HTML code before "<?" it worked fine! But I still need that code to remain there.. It used to work before, So how can i make it remain there without causing any errors?..thanks

<p align="center"><font face="Trebuchet MS" color="#21AEBD" size="2">Step 1
Discussions<br>
</font>
<img border="0" src="images/verticalbar_HORIZ.GIF" width="150" height="9"></p>
<?
error_reporting(E_ALL ^ E_NOTICE);
/**************************
* txtShout v1.3 *
* ©2004 - Thomas Love *
* *
**************************/
// Use of this software is subject to
// agreement with the terms of the
// included license. See license.txt.

$timer = microtime() + time();

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
 
AFAIK there is no way to have output before headers, nor was that ever possible. You could use output buffer to control when something is printed out by that is not what you're looking for. Looking at your headers the only thing I can suggest is simply using regular meta tags. You can easily put those in the head portion of your html and they will work as well as php headers you are sending.
 
Headers are called headers because they are the HEAD of all HTTP communications. There is nothing before them and there is absolutely no need for anything before them. AFter the headers comes the content, your HTML code.
The headers set up the client to know about what is coming from the server, e.g. MIME type, how the chaching should be handled, status code etc.
You need your HTML, put it after the extra headers sent.
 
Hello again guys,

Thanks for your help. I understand what you guys mean now :)... One question though, how did the script work fine before with no errors? Weird...
 
you might wanna try this: after the header() functions, add this code so you can still send headers and still use the HTML.

Code:
?>
<p align="center"><font face="Trebuchet MS" color="#21AEBD" size="2">Step 1
Discussions<br>
</font>
<img border="0" src="images/verticalbar_HORIZ.GIF" width="150" height="9"></p>
<?php

---------------------------------------
 
Your the man thenewa2x!!! Got it working... Thanks everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top