Page 1 of 1
How do I resolve the "Cannot modify header information..." e
Posted: Fri Jun 06, 2008 1:40 pm
by repp9418
My environment is:
PHP 5.2.5
Apache 2.2.8
W2k3
IIS 6.0
I am trying to run the following code to test a connection to a DB server. There are not spaces above or below the PHP tags.
Code: Select all
<?php
include('adodb/adodb.inc.php');
echo 'hello world';
$dbora = ADONewConnection('oci8');
echo '<br>connection created<br>';
flush();
$dbora->Connect('XXX', 'hrs', 'XXX', 'SID'); //TNS:Connect timeout
echo '<br>connection established<br>';
flush();
?>
In this code I was getting a timeout error. I put the flush calls in so the error would display on the page right away. The flush tags are causing the following errors.
Code: Select all
[06-Jun-2008 14:28:41] PHP Warning: Cannot modify header information - headers already sent in Unknown on line 0
[06-Jun-2008 14:28:41] PHP Warning: Cannot modify header information - headers already sent in Unknown on line 0
The errors are generated only in Apache. In IIS I do not get these errors. Does anyone know why?
Thanks
Re: How do I resolve the "Cannot modify header information..." e
Posted: Fri Jun 06, 2008 2:48 pm
by Jaxolotl
did you try searching before asking? this topic is frequently asked
the server is telling you that you already send the http headers and you're trying to do it again when it's not possible to send them more than once
Check if you have error reporting to E_ALL and tell us what it's coming out, maybe something there is sending an unespected header
for example you are sending echo 'hello world'; to the output, if for any reason ADONewConnection('oci8') or Connect('XXX', 'hrs', 'XXX', 'SID') is trying to send another header like header('Location: something') you're in trouble
PHP MANUAL wrote:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
http://www.php.net/header
Re: How do I resolve the "Cannot modify header information..." e
Posted: Fri Jun 06, 2008 3:03 pm
by Benjamin
Are you even sending headers anywhere?
Re: How do I resolve the "Cannot modify header information..." e
Posted: Mon Jun 09, 2008 7:55 am
by repp9418
The above code is EXACTLY what I am using. There is nothing more to it. I browser to test.php, which is nothing more than the code above.
I promise I have googled this for 2 days before I posted it on here. I am not calling header() and I do not have any spaces above or below the <?php ?> tags. Those were the only responses people gave for resolving this issue.
At this point I am thinking this is a php.ini setting or an Apache setting that is causing this, but I am not sure which one. I was hoping someone could point me in the right direction.
Re: How do I resolve the "Cannot modify header information..." e
Posted: Mon Jun 09, 2008 8:26 am
by Rovas
Try using this
function to see what headers the server sent and from where. The comments on that page are helpful. You might have the options for caching files activated, when the caching options are activated they usually send headers for caching. For caching activation you have to check the IIS configuration. I haven' t worked with IIS 6 only with the v5.1 version. From what I remembered you have to look in the Properties window for folder that contains the site. There in one tab is the caching options. I' m not sure because I haven' t worked with IIS from about 2 years.
Re: How do I resolve the "Cannot modify header information..." e
Posted: Mon Jun 09, 2008 12:08 pm
by Jonah Bron
This code may not be sending any header information, so it is likely that the ADONewConnection class is sending the headers, after you have echoed. Try running the same code without any echos, and see if it works then. Am I correct in assuming that the echos are for debugging purposes?