|(6 intermediate revisions by 4 users not shown)|
|−|Q. What causes "Warning: Cannot modify header information - headers already sent " to appear? |+|
| || |
|−|An example: |+|
the phpfile of the , the of
|−|I have Mambo pretty much installed, but when I get to the index.php file of the site, |+|
|−|it has the mambo default site with the following lines above it: |+|
|−|(example of error code displayed) |+|
| || |
source lang="php"> GLOBALS[$key2]=$value2; } } } ?> </ source> |+|
|−|Warning: Cannot modify header information - headers already sent by (output started at |+|
<>?></> -headers sent.
|−|/home/somesite/somefolder/anotherfolder/folder/globals. php:44) |+|
|−|in /home/somesite/somefolder/anotherfolder/folder/includes/mambo.php on line 274 |+|
| || |
| || |
|−|A. PHP files cannot have any blank spaces/lines outside the PHP code and will result in this type of error . |+|
|−|There cannot be any white space or blank lines either before or after the opening and closing PHP tags (). |+|
any the this error be and can .
|−|A single extra character, even a blank space, can cause this. |+|
| || |
|−|Look at any files that you have modified to see if there is any such space. |+|
to, , to
|−|Online file managers, such as used in cPanel, when used to edit files will often add a blank line at the end of the code. |+|
|−|Always check for extra spaces/lines after the PHP code before saving .php files. |+|
Latest revision as of 22:44, 12 April 2011
In the HTTP protocol a server response consists of a group of headers followed by a body, separated by a single blank line (i.e. a line containing only a carriage-return). This warning message is produced by PHP if a program attempts to send an additional HTTP header after the separator (and hence all the headers) has already been sent.
By far the most common cause of this problem is that one or more PHP files contains characters (usually a space or an empty line) outside of the <?php and ?> tags. To fix the problem you should examine the PHP file indicated in the warning message and remove any blank characters at the beginning and end of the file. Some text editors, including some online file managers, are prone to automatically adding extraneous line-ending characters at the ends of files, particularly when not configured to do otherwise.
- Remove the closing ?> tag at the end of your PHP files. It actually serves no useful purpose as the PHP interpreter knows that end-of-file means end-of-PHP too. Removing it means that any extra blank characters added by your editor will have no effect on the output generated and so will not prevent additional HTTP headers from being sent.
Turn output_buffering setting on php.ini to on to permanently remove this error.
- Other Tips
- Remove the echo or print or any other statement which prints something on the page. By removing all such statement, this error will be removed and you will be able to modify header information - in other words - you can use the header function.
- Go to: Global Configuration/System, disable web services, re-enable web services(if that doesn't work)set session handler to none,(apply)then change back to database(apply) :) Enjoy