By heyw00d on
Hi.
the index page is displayd correctly.
problem is: when i want to log in as 1. user i'll get this errormessage: "warning: Cannot add header information - headers already sent in d:\web\drupal\module.php on line 12."
and i can't see any content.
where is the problem?
drupal 4.0
apache 1.3.27
php4
mysql 3.23
on win98se
Comments
next problem
...so i pass this problem, and encountered to another similar:
warning: Cannot add header information - headers already sent in
d:webdrupalmodulesuser.module on line 566.warning: Cannot add header information - headers already sent in d:webdrupalincludescommon.inc on line 320.
is there problem with my php?
php
hi
i had a simular problem some time ago (apache, mysql, linux) and it had to do with php (not drupal).
make sure that your includes and extensions dir both in php.ini and conf.ini are set right. did the trick for me
--
groets
bert boerland
.
... couldn`t find any conf.ini file in my drives and no related files with includes and extension dir...
Strange...
...but suddenly it`s working.
am I happy? no - don`t know how it happened.
i was getting those too...
it turns out my problem was, after downloading a module or editing a page, my text editor was adding extra blank lines after the last line of code in my php files.
opening up the files and deleting the blank lines fixed my problems with 'headers already sent'
Did you find the solution?
I have the same problem, Do you have the solution?
I have the same
I have the same problem,too.
Does anyone know how to solve it?
Will drupal update and fix the problem?
my experience
Just for the record I thought I'd add my experience as it might save someone a few hours debugging. I added a new function to my template.php file. I start getting 'the error'. I frantically look for blank lines, buggy code and anything else suspect. The cause was this:
A single space after a closing '?>' from the previous function. Meh....
This might be your problem, check it out
--
Neil Cameron
Why wrap functions with
Why wrap functions with
...to begin with?Just put
at the top, you don't need a closingDo that and you won't have to worry about trailing spaces.
--
Jakob Persson
Drupal developer, web designer and usability consultant
http://www.jakob-persson.com
--
Jakob Persson - blog
Leancept – Digital effect and innovation agency
thanks
finally someone whos able to give the right answer! thanks so much
Hi Jakob, Do you mean my
Hi Jakob,
Do you mean my template.php should look like this? I'm sorry, I don't know anything of php:
Thanks for your help!
Els
WOW!
MAN!
Thanks Huitalk!
That was it! I can't believe this, I nearly lost a day!
cheers!!
Dan.
strange but true...
...it seems that if there are extra carriage returns after the last line in the XXXX.theme file [ ie. after the '?>' ],
then this error is thrown when logging in....
simply remove the extra CRs and you should be sorted...
Name of the theme?
What theme are you talking about? Tell us the name of the culprit and we can fix it in CVS.
I started getting these errors ...
After adding the theme editor mudule. Once I removed (deleted) the module, my errors went away. Hope this helps.
empty end of line
at the end
--
groets
bertb
--
groets
bert boerland
Regarding: Cannot add header information - headers already sent
I seem to have the same error here.
Could you please tell me how to fix this?
- Kenneth
I just downloaded and install
I just downloaded and installed 4.3.2 and this exact error popped up from the start. After some poking around, I found 3 extra CR's at the end of the /includes/conf.php file. After removing them, the problem ceased. Prior to that, I had removed a single extra CR at the end of every .theme file present in the themes directory--this did not affect the problem, but I wanted to list ALL the steps I took that resulted in the solution.
still a problem
I'm getting a similar error, at various times, not just login: "warning: Cannot modify header information - headers already sent by (output started at [path]/interlaced.theme:3) in [path]/modules/user.module on line [it varies]." As noted in the comment above, it tends to go away and come back again randomly -- though relaunching the web browser seems to help, so I am wondering if it is related to the path or some such? I checked for extra carriage returns in the .theme file and there aren't any. Should I be looking for carriage returns anywhere else? Any other thoughts on how to fix this?
same problem for me
i've installed drupal on my localhost and then on my site (www.iusseek.com/news)
Until I Used marvil theme i had this problem.
I've changed with another one, and there are no more problems.
I hope will helps to discover the bug. I've tried to comment the header tag, but it's not enough.
dott. Spataro
Solved a problem for me!
I had written a couple of small modules for my own use and couldn't figure out why I was getting this 'headers already sent' error when I used them. Many thanks for revealing this simple solution! It stopped me scratching my head in perplexed frustration! I just removed a trailing CR on both module files, and the problem disappeared.
Fix
As stated all the kind people from other comments...
Just remove trailing new lines from all files you ever touched (*.php).
Seems like some editors add these lines (from KDE for example).
I am using Drupal 4.4.0
p.s. I'm at http://vova.org
The same problem
Something at my server insists to put the extra carriage returns. I have see that this is a very commom problem. There are not a workaround to it?
Had the extra CR (Cannot add header info) problem AGAIN...
I had the same problem. Thanks to all who mentioned the extra CR's! It fixed my problem!
I had edited the chameleon.theme file, and my server (I edit the files in a web page) apparently adds the extra lines when it OPENS the file.. Not when it saves it. So now I know to delete the lines BEFORE saving it. Works every time now!
warning: Cannot modify header information - headers already sent by (output started at /home/edingo/public_html/drupal/themes/chameleon/chameleon.theme:164) in /home/edingo/public_html/drupal/includes/common.inc on line 155.Having the same problem
Do you have any suggestions on how to locate the 'offending file'?
"the long tail"
dont know but it shouldnt be too hard to do some tail -1 on all files and grep for an empty line.
--
groets
bertb
--
groets
bert boerland
Possible solution
I had a similar problem few days ago and I found another reason for it.
Open your php.ini file [wherever it is] and check your error_reporting setting
Mine was
error_reporting = E_ALL
See what I found for that :
; - error_reporting = E_ALL [Code Cleanliness, Security(?)]
; By default, PHP surpresses errors of type E_NOTICE. These error messages
; are emitted for non-critical errors, but that could be a symptom of a bigger
; problem. Most notably, this will cause error messages about the use
; of uninitialized variables to be displayed.
So I decided to change it to
error_reporting = E_ALL & ~E_NOTICE
and everything went fine.
I hope that it will help you :)
Same problem to me!!! :-(
warning: Cannot modify header information - headers already sent by (output started at c:\webroot\japan\includes\common.inc:1) in c:\webroot\japan\includes\common.inc on line 1260.
warning: Cannot modify header information - headers already sent by (output started at c:\webroot\japan\includes\common.inc:1) in c:\webroot\japan\includes\common.inc on line 230.
And I have checked most (all?) files and now they have no extra carriage return, plus I do have
error_reporting = E_ALL & ~E_NOTICE
in my php.ini
Any idea?
(I'm feeleing stuck in front of a white page) :-(
Thank you in advance,
hip
well known
this is a well known problem. searching for this on both drupal and google will give you many hints. please check your files for "empty lines" at th end of the file (after the php>) and delete these lines.--
groets
bertb
--
groets
bert boerland
And I have checked most
Reinstalled everything and
Reinstalled everything and no 'headers problem'. Don't think will ever know what happens but it seems to work now. I won't touch it as far as I can.
Tanx anyway,
hip
Its a two part problem.
Its a two part problem. First when you do an install there are some files that have ^M or at the end of the code usually between the last line and the closing ?> tag. This gets put into the cache tables, this is why when people disable the cache or clears the cache table the problem goes away. Unfortunatly depending on how you unpacked the files or how they were packed for distribution wont elimiate the problem you just have to find them and squash them. One other tidbit, it you are using a Text Editor that allows you to choose the file mode, set the mode to the system you are using, I use HomeSite and I am on Linux so my file mode is set to UNIX, that way I dont introduce any or ^M characters.
Eliminating Empy Lines worked for me.
Just FYI: I had the same problem (started after the first time I ran my cron.php, not sure if that is what caused it). Anyway, getting rid of the empty lines after the very last tag in the file fixed the problem for me. I had to go through several files to do so, however, it was relatively simple since the error message tells you what file has the problem (e.g. conf.php line xxx or help.module line xxx).
Thanks to those posting fixes to this problem.
Peter
flag output_buffering in php.ini
Try to activate the flag output_buffering in the php.ini. It may solve the header problem.
For instance:
output_buffering = 4096
This is the fix!
I moved my sites to a new server build and started getting these errors. Enabling the output buffer fixed the problem immediately. Dave
something fishy
I spotted something funny in my index.php file when hunting down the solution to this problem, maybe it will help you out too.
The very first line of my index.php file should start with standard php start tag but instead some sort of iframe got tagged in there, I don't know how it happened.
What my index file looked like was:
It should actually have an open < before the iframe, but this site kept telling me I have 'suspicious content'.
I uploaded a new index file and it obviously went away. Where and how did that code get inserted? Was is something that my drupal install generated or was that an outside attack on my index.php file?
Exact same problem
I had the same weird line in my index.php. i uploaded the originia that came with drupal and it solved the problem.
Warren County, Virginia News & Networking: http://warrencountyreport.com
Cache settings
I am using windows/firefox/php4. when enabling Cache support, the error occures. I diseable it, and things go better. How to fix that in the drupal_page_header() in file bootstrap.inc Thanks for your reply.
Warning: Cannot modify header information - headers already sent
I finally broke my Drupal installation after a good amount of tinkering and even made the mistake of changing my DB charset from Latin1 to UTF-8 and back.
There is the reason how I got this error. I changed the Charset of mySQL DB to see if I could get rid of the error im phpmyadmin and it gave me error messages immediately (this attempt is detailed in a different account on my website), but when I switched it back to Latin1 (phpmyAdmin keeps saying Swedish Collation), it worked for about a day and I think that I installed a module that ran an SQL command that clashed against the existing mismatch due to flipping the Charset midway, and it all went downhill...
I am detailing this on my technical blog at http://www.cmsproducer.com/click/78/2 instead of filling drupal support with length detail.
-----
Web Development & Production Advice - http://www.cmsproducer.com/click/26/2
Drupal PHP/Mysql error - Cannot modify header - Hiding the error
I created a new DB (after the above issue) in quest to get to the bottom of the problem. Initially, I had suspected that this was only happening cause I tinkered with the database and because I was running on Windows (Don't we all end up blaming Mr. Gates when things don't work), then I noticed the same error in my Linux installation (less frequent though - about once a week)!
I have still not been able to zero-in on the cause of this error-message. I am living with it, and whenever I have time, I browse the web and read manuals for answers. To hide the problem from my visitors, I set Drupal (admin->settings) to hide error messages from the screen and only write them in the watchdog log. The error message does not seem cripple Drupal (besides the unsightly log) that much and it does not help to announce to your users that you are struggling and sinking in the back.
-----
Web Development & Production Advice - http://www.cmsproducer.com/click/78/2
This is great
For those of us who have checked every php and inc. file, this is really the best solution.
www.thecarbonpig.com
Wondering about my supposed fix
So I was getting this same error
Location /drupal-4.7.0-beta6/?q=admin/aggregator2/refresh/1556
Referrer http://localhost/drupal-4.7.0-beta6/?q=admin/aggregator2
Message Cannot modify header information - headers already sent in /Applications/xampp/htdocs/drupal-4.7.0-beta6/includes/common.inc on line 233.
Severity error
Hostname 127.0.0.1
Whenever I refreshed my feeds for aggregator2 I would get that error. So I went to line 233 and commented out
header('Location: '. $url);
Now the error has gone away but I am wondering if this code is more vital, nothing looks like it has broken but I am hoping that commenting out this line won't cause anymore errors in other places. I tried getting rid of all the white spaces and it still gave me errors and the only thing that worked was getting rid of that line of code.
[edit]Ok so I found out that it's not a valid fix for my problem. So if anyone ever reads this it's not worth it. It messes up how other things save. I might try writing a a new function to do what the drupal_goto does but to take out that one line just for when the refresh feed items happens
Check your template.php file
I had the exact same problem:
I wanted to define some regions as explained here:
http://drupal.org/node/29139
I didn't have a template.php file so I made one and pasted in this:
that I got from a different file. (Hey, what do I know. I was just trying to make a well formed file.) That was the problem. When I removed everything from the template.php file except for the php function to define the regions then all went back to normal.
SpryDev Drupal Developer
--Ben Finklea, CEO
Volacci
Same problem here except...
This is the second time I'm having this problem. The first time (a couple of days ago) I solved it by follwing you advices, namely removing all the residual white spaces at the end. Problem solved. Brilliant.
Now it hit me again. This time a little different. I'm currently making my own drupal theme based on the default pushbutton theme. The culprit is, again, the template.php file as the probelm doesn't occur whenever I delete template.php file from my theme directory. Here's the real interesting part though. I got a "fresh" template.php from another theme and put it in my current working theme directory. No problem there (though naturally my overridden functions don't work because I haven't renamed them yet). But get this as soon as I make any change to the template.php file, I start getting empty white pages, "header..." errors whenever I hit a submit button to pass some information to the server. ANY change at all. In fact, it happens even when I open the template.php file and don't make a single change and just resave it on my editor (ultraeditor) and then upload the file to the server. Now I'm really stumped.
I'm guessing it has something to do with my text editor (probably one of its settings) and how it handles text files. Maybe it adds some data or mess with the encoding or something. When I save the original template.php as new the resulting file is 3 bytes longer but they seem to show up exactly the same on a hex editor.
Any suggestions? (short of looking for another text editor or doing away with template.php)
Okay I seems to have found
Okay I seems to have found the solution to my own problem. I went to Ultraedit's settings and then unchecked the "autodetect UTF-8 file" option.
problem solved
Okay I seems to have found
jihanj - July 27, 2006 - 11:28
Okay I seems to have found the solution to my own problem. I went to Ultraedit's settings and then unchecked the "autodetect UTF-8 file" option.
<--
This was the problem. Thanks, I switched the file of my module back to ANSI type, it worked.
Thanks
Waqar
anyone found a viable solution to this...
i'm having the same problems and i'm pretty sure it is a server side PHP error. I have two sites running on 2 different servers; on one Agg2 works perfectly, on the other i get the header problem. Both sites have identical drupal versions, style sheets, etc. so it has to be a server issue i imagine. i'm not the server adminstrator though and would like to be able to notify them to make any tweaks if that will fix the problem. any words of wisdom?
drupal 4.7.2
latests Agg2 build
thank ya kindly,
c
Prolem solved for me...
applied this patch:
http://drupal.org/node/60396
The same problem
See my site: www.onlinecasinowatch.net
How do I solve it?
I kept getting this error
I kept getting this error all of a sudden, it referred to template.php:1 and common.inc. There were no extra newlines. I realized eventually that it all started when it changed the encoding of template.php to UTF-8. I am using Dreamweaver 8 to edit the files and there's an option called "Include Unicode Signature (BOM)", unchecking that box fixed the problem.
--
Jakob Persson
web design and usability consulting
http://www.jakob-persson.com
--
Jakob Persson - blog
Leancept – Digital effect and innovation agency
Changed file encoding from UTF-8 to latin1
Changing the encoding of template.php from UTF-8 to latin1 did the trick for me. Now to sit back and wait if the problem comes back again...
I had the same problem
I had the same problem, the header error message. It started when I wanted to edit the theme.inc file in the includes folder.
I only use notepad as my editor, so I figured that it wouldn't effect the file other than the changes I made. I was wrong.
I was able to fix the problem by changing the encoding back to ANSI from UTF-8. I guess one solution for this problem is to check the encoding of the files before you save them in your editor. And be sure to go slow, don't make too many changes to too many files before you test them out. This way you can isolate what changes caused what problems.
apt94jesse: Try using
apt94jesse: Try using ConText instead, it's a free editor which beats Notepad totally: www.context.cx
--
Jakob Persson
web design and usability consulting
http://www.jakob-persson.com
--
Jakob Persson - blog
Leancept – Digital effect and innovation agency
thanks
Looks good, I just downloaded it, should help a lot. Thanks!
The guy was right about adding extra lines at the end of file
My editor was also adding blank lines and hindering CIVICRM from even opening. Thanks for the guy who wrote the solution was Just go to the end of the settings.php file - delete extra lines and everything works fine. whew for someone who is not a computer geek I was happy to find an easy solution!
Thanks for the spaces tip
I just gotta say I love the open source community. not 3 minutes after encountering this header sent issue i hopped onto the forums and found the solution right away. I love you guys.
- Roley Chiu
www.rollsonline.com
Comment fields were causing problems... Still breaks Andreas09
Heyllo everyone:
The following worked for me... I just removed all my comments from the template.php file and left solely the contents posted here:
However, this still breaks the Andreas09 theme.... any idea why? It ruins my header bar and primary links to show up small and horizontally, not vertically...
Thanks,
Adam
How can I edit the xml:lang value for each individual page?
I need my site supporting two languages for different pages. How can I do it with customizable xml:lang at the html tag?
Elvis
Internet Marketing Watch : http://elvis.hk/
Personal Computer, News and Media
Same problem!
I had the same problem when editing the template.php file. I traced it to having copied a block of code from a module readme.txt into my editor! The CR is definitely creating the problem.
Yannis
So to sum up the whole tread
So to sum up the whole tread (thats the impression I have since I had the same problem):
From the day you host your drupal site you will never rest calm because you never know when and why the header load error occures because on of the files you edited was done with the wrong editor settings or one of the modules you installed is causing the problem (maybe because the guy who wrote the module used different editors, had a different operating system or different editor settings).
This happened the second time to me now just by enabling the "wrong" module. This time I fortunatly right before backuped my site. The only thing I did was enabling the csv profile module and it started. I checked every php file twice (about 150...). Then I installed the backup locally - it worked. I enabled the csv profile module - It worked fine, no errors. I imported the backup on my life site and enabled csv profile module - the same header error again...
just turn off the output buffering
just turn off the output buffering in the php.ini,
or create a php.ini in the drupal's root, with content:
output_buffering = offhttp://eaposztrof.com/drupal | save the planet, kill yourself!
blank login logout pages and session regerate
had the same problem
went through the template.tpl.php and removed all BLANK SPACES! between functions and at the end of file after the ?>...
thanx for all the help
default.settings.php file missing
Did you change the name of sites/default/default.settings.php to simply settings.php?
if so, you will get this error.
You must copy default.settings.php, rename it to settings.php, and leave the original in place.
Utf-8 without BOM
I experienced such a problem while developing a custom module.
Encoding .module file (which caused the white screen problem) with utf-8 without BOM helped to solve it.
Does anyone know if there is
Does anyone know if there is a correct/incorrect encoding type for files such as template.php and .module files?
Thanks for the support!
you might also not have
you might also not have template.php utf-8 encoded, that was why I had this warning.
hi
The Problem is also because of any echo messages in the code before the header function. It worked for me by removing those echo messages.....
this happened when I switched hosts to greengeeks
Hopefully, this will help someone else. This happened for me when I switched hosting companies. I had to change "mysql" to "mysqli" in the settings.php file and the warning went away.
Same error, tried all suggestions but still the same error
Hi,
I had a similar problem with "Warning: Cannot modify header information - headers already sent by ..." I followed people's suggestions to delete the extra spaces at the end of all the inc files and made sure I didn't save it with the bom. None of the inc files have a closing php markers. However, the error still persists.
Weird thing is that no one touched these files to begin with, and this error message popped up out of nowhere. We were only adding content through the administrative interface.
Are there any other solutions we haven't tried?
Thanks.
problem solved
Actually my error was completely unrelated to this. It was solved following this post: http://drupal.org/node/1219964
Other solutions at
Other solutions at http://drupal.org/node/1424
My update blank page was
My update blank page was solved simply re-copying core themes I had removed because I (stupidly) tought they was useless.
So I re-copied bluemarine, chameleon, garland and pushbutton to ROOT FOLDER/themes (not sites/all/themes folder) and the update page re-appeared again!
Hope it helps someone who toughts, like me, core themes weren't useful! :)