I am tacking this error message:

warning: Cannot modify header information - headers already sent by (output started at C:\apache2triad\htdocs\drupal52\themes\testdiavloi\template.php:127) in C:\apache2triad\htdocs\drupal52\includes\common.inc on line 309.

What does it means ?

Comments

styro’s picture

have a closing PHP tag at the end? ie a ?>

If so, delete it to prevent the whitespace after the closing tag causing problems.

If not, which other PHP files have you edited? You should check those too.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

michellelaham’s picture

I have not modified any of the php and havent accessed my site in a while..(been too busy with other work). I visited it today and received the following warning that wasnt there months ago when I last accessed the site. Any ideas of where I should start? I am absolutely clueless when it comes to bebugging and usually start over from scratch when an error like this occurs. I just dont want to scrap this after building the back end of my future website...I think it may have something to do with updates or something that has changed since i last accessed the site...

Any ideas? Please and thank you in advance for anything you can offer..

Here is the warning message that occurs on my site (www.duderina.com)

Warning: Cannot modify header information - headers already sent by (output started at /nfs/c08/h04/mnt/123296/domains/duderina.com/html/includes/common.inc:2561) in drupal_send_headers() (line 1040 of /nfs/c08/h04/mnt/123296/domains/duderina.com/html/includes/bootstrap.inc).
PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ) FOR UPDATE; Array ( [:db_condition_placeholder_0] => ctools_last_cron ) in variable_set() (line 805 of /nfs/c08/h04/mnt/123296/domains/duderina.com/html/includes/bootstrap.inc).

xjessie007’s picture

I had a problem with the "headers already sent" too at my www.Maxi-Pedia.com website. In my case, it was caused by a blank line at the beginning of common.inc. Drupal or more likely PHP seem to have problems with extra spaces here and there.

Check all your *.inc files to make sure you do not have closing ?> in any of them. Closing ?> is not needed in your *.inc files. Check all your *.php files to make sure you do not have blank lines at the beginning or at the end.

If the error message indicates that this is caused by some module, disable your modules one by one to find out which one causes this.

This can also be caused by UTF-8. If you have your website coded in ASCII and are saving your php files as UTF-8, it can cause this message. If your website and DB are UTF-8, you should be ok with saving php files as UTF-8 though.

I heard this could also be related to blocks that do not have a title specified. Edit your blocks in Admin / Blocks.

Btw, this error message is related to output_buffering on/off in your php.ini. If you have output_buffering set to some cache, the server will allow to send headers with delay (or to modify them shortly after they are sent), and this error will not be tripped. But if you set output_buffering to 0 or not at all, then headers can be sent at only one moment, and if you have some bad code, it will trip this error message.

------------
Everything you ever needed to know: www.Maxi-Pedia.com

jimzaptech’s picture

Hi, I configure our client website on dedicated server from there I have same problem, Then after changing OUTPUT_BUFFER=OFF to OUTPUT_BUFFER=ON solve my issue. Thank you for guide line.

sbefort’s picture

I can confirm that UTF-8 encoding may cause this problem. I was writing a module that had 3 files encoded in ASCII and one in UTF-8 because I was experimenting with Chinese characters as array keys. I forgot to turn the UTF-8 encoding back to ASCII and noticed this error in my log 3 days later. I never thought to check the file encoding again until reading this. Thanks!

rodrigo panchiniak fernandes’s picture

I've solved the issue disabling some performance settings: page cache -> caching mode, Bandwidth optimizations -> Optimize CSS files and Optimize JavaScript.
Using a shared server with a neurasthenicly secure profile.

digitalpbk’s picture

Remove the closing tag at the end of the template file or remove spaces that are output before the and after the ending technically the last ?> is not required.
See Solve Warning cannot modify header information for more technical details and additional solutions.

Francewhoa’s picture

Other solutions at http://drupal.org/node/1424

Loving back your Drupal community result in multiple benefits for you