Warning: Cannot modify header information - headers already sent by

Permalink 1 user found helpful
Hello everybody!

I really need some help with this issue... Recently I've been getting the following error whenever my site loads:

Warning: Cannot modify header information - headers already sent by (output started at \\cpt.wa\webs\Data01\Spaces\EIP01\loveandyoga.co.za\wwwroot\index.php:1) in \\cpt.wa\webs\Data01\Spaces\EIP01\loveandyoga.co.za\wwwroot\concrete\libraries\controller.php on line 333

This is the code that appears on the offending line: header("Location: " . $url);

I have no idea what to do and I cannot log in to the dashboard for Concrete - all I get is a blank screen with that particular error message on it.

This is the site's URL:http://www.loveandyoga.co.za/index.php...

Can anyone help me with this issue?

View Replies:
ScottC replied on at Permalink Reply
You probably have a space above the <?php tag in your index.php
CaptainUnobservant replied on at Permalink Reply
Hmmm... If it's that simple I'll kick myself! Let me try it quickly!
fastcrash replied on at Permalink Reply
maybe you echo/print_r something in that file shown that error, and forget to recomment it
CaptainUnobservant replied on at Permalink Reply
Nope, no luck...
mkly replied on at Permalink Reply
also check /config/site.php for extra space, errors or just things outside of the
CaptainUnobservant replied on at Permalink Reply
Everything's clean and clear there... This is incredibly frustrating! It actually just randomly appeared today, everything was working fine yesterday!
fastcrash replied on at Permalink Reply
remembering me old days, that is the first trouble error, beside 'unexpected error..bla3x' i encounter when i start learn php
CaptainUnobservant replied on at Permalink Reply
Sigh, and now I'm in that exact boat... Trust me, I'm a complete noob with PHP and all this nonsense is greatly depressing! How did you manage to sort this out?
fastcrash replied on at Permalink Reply
you must remember what exactly file you have change before this error.
like scott said, only extra space after php close tag '?> ', will throw this error, session/cookie output/echo/print_r before header
ScottC replied on at Permalink Reply
Any whitespace outside of a php tag is a killer, so be sure to isolate your install(as in not trust your zip file) as a culprit.

You can unzip and load things in your text editor and they will sometimes insert a blank line or something else..so first you need verify that your download is correct. If this were a widespread issue you'd certainly hear more about it, so I'd double check your download first and install it locally on mamp or xampp or something first.

I'm sorry you're going through this issue but you need to start from the most simple validations and work out from that.

CaptainUnobservant replied on at Permalink Reply
I'll certainly give it a shot... I'm at a total loss though, especially because I can't log in to the site at all!
mkly replied on at Permalink Reply
If you look at the error it actually says
headers already sent by (output started at \\EDITED\EDITED\EDITED\EDITED\EDITED\loveandyoga.co.za\wwwroot\index.php:1

See that :1 part. It probably means line #1 or index.php. The thing is that concrete5 does little or nothing in that file. It typically only contains this.

There should be no spaces before the

and no lines above it. Those two lines are the only thing that should be in it.

Sorry to hear you are having a tough time. Honestly, it's very solvable, we just need to narrow it down and find the place that is outputting that line.
CaptainUnobservant replied on at Permalink Reply
This is the code as copied from the index.php file...

I've tried everything! This is getting massively frustrating... I did find an extra line in the index file, so I deleted it and tried again, but it made no difference.

The strangest thing is that when viewed from one computer, all of the CSS is blocked and unresponsive, but when I check on other computers, all the CSS is working, but the error is still there... This is the strangest thing ever!
jj0 replied on at Permalink Reply
Did you ever find a solution to this, as I'm having the same problem.
CaptainUnobservant replied on at Permalink Reply
Hey jjo, unfortunately not! I ended up deleting everything from the server (who SUCKS, by the way), using a fresh install and starting all over...

I have a feeling that it has something to do with me attempting to build the whole site offline first, because I had no hassles whatsoever when I did everything online... I hope you come right though, it was the most frustrating thing imaginable!
sherri333 replied on at Permalink Reply
Thank you for this information! It helped tremendously.
martinmb replied on at Permalink Reply
Just in case this helps anyone stuck on this one. I had this error and the fix in my case was to carefully go through all the pages in my package and check the Unix line terminators. Its obvious they shouldn't be DOS but my new package controller.php files had sneaked past as Unix-Utf not Unix and it was causing a problem with view.php APP_CHARSET. I assume because I had copied the script body from the C5 webpage example and it depends on your editors save behavior.
tonidomenech replied on at Permalink Reply
It's error is to use a \"print_r\" in the core/cake/libs/controller/controller.php outside a frame for text. "
VPenkov replied on at Permalink Reply
Also, another reason would be closing your PHP code with ?> inside your config.php file.
You shouldn't close your code with ?> at the end of a file if that file contains _only_ PHP code.

This would disallow you to add data to your header information and can screw up a few other things, as per the Zend documentation.

Here's a few more details, quote from the docs:

The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.
rritz replied on at Permalink Reply
I got the Warning: Cannot modify header information - headers already sent by ...

and the only thing I edited was config.php (moving the site, adding different database info)

The error was thrown in concrete/core/libraries/view.php in line 173 wchi is the last line of these:

public function addHeaderItem($item, $namespace = 'VIEW') {
if ($this->resolveItemConflicts($item)) {
$this->headerItems[$namespace][] = $item;

I tried removing closing php tag from config.php but this caused my site to just load blank pages

Can you help?
wishvisit replied on at Permalink Reply
Hi I hope you guy already solved this.

I got this problem too.When working with Pagecontroller.

-I've error massage Warning: Cannot modify header information - blah blah blah in controller line 1.
-my first <?php in controller page is clear of white space.
-some page got this error some not.

And I've found that some of my page controller (in controllers\page_types\xxx.php) is encode in UTF-8.(because I'm work in Asian lang.)

When I'm change back to ANSI it's work pretty well.

Hope this help you guy.
cjramki replied on at Permalink Reply
I also got this same problem, I got the warning at the EOF

I deleted my php close tag (?>) in my controllers.
Its Working fine ;-)
sully210 replied on at Permalink Reply
OK, I don't know if this is going to help anyone or not but I just went through 5 days of hell trying to get my theme to work with Bootstrap and had similar problems when trying to put it all back together. I know Bootstrap is off topic but I thought I would warn anyone thinking about using a Bootstrap based theme of the inherent dangers. I really don't know what happened but I installed the Rigid Light theme on my site to use as a responsive splash page while my clients and I were figuring out what to do design wise. I purchased a theme and activated it on all of my pages. C5 uses the same ids and classes as Bootstrap so there was a major problem with the css getting caught on their stylesheets, mccm.app.css, so my styles were not rendering on my site. Anyway, I got that all straightened out without putting a bullet in my head or laptop or both. I finally had my site looking the way I wanted to and published a home page and a contact page to at least have something that looked decent for my clients. Things were great for about an hour and then all of a sudden, I went to test my site in all 5 browsers and they looked completely awful! Some of my css was rendering but the majority of it was not. It took me about an hour of scouring until I realized that for some reason my head tag was echoing the style sheet from the slider that comes with Rigid Light as well as the .js file??? I couldn't figure out why and never did. I had already deleted the theme from my add functionality page but the files were still in my packages directory. I tried every trick in the forums including overriding the css with site_theme_paths.php file in config, moving my theme to the root themes folder and changing the paths, deleting the Rigid Light files, etc. There are a lot of answers out there but noone had my particular problem and I couldn't fix it. Well, it's superbowl Sunday and I didn't catch a lick of the game. Not reallly a huge sports fan but it was the superbowl. Every time I got an error like this I just replaced the existing file with the original file and somehow it seemed to work. I had to do it for almost all of my addons. I finally got a new free theme from the marketplace developed by the core team, there was only one, Holiday Yogurt, and installed that. I made sure that my header no longer echoed the Rigid Light css and then got rid of the theme all together after deleting it and releasing it from my project a few times, I then deleted the directory all together because although i checked the box to move the files to the trash, they were still in my packages folder. Finally, I reactivated the theme I bought and now I am probably on my way to disaster again but I have lost a week of my life on this site and I am not giving up. I posted a bug report that you can see here:http://www.concrete5.org/developers/bugs/5-6-2-1/css-hijacked-by-de...
There is a screencast in this post and you can see exactly what was going on before I went through all of this. I really hope this helps someone and if you have any questions or need help I would be happy to oblige, I have gotten some really great help in these forums and my life has been saved more than once between the good people here and at Stack Overflow. I am certainly no expert at this but I am tenacious and if I start it, I will finish it! Good luck and best to you and yours,

pjgruen replied on at Permalink Reply
I had the same problem

Warning: Cannot modify header information - headers already sent by (output started at /public_html/concrete/libraries/3rdparty/adodb/adodb-xmlschema03.inc.php:1)

It turns out that somehow adodb-xmlschema03.inc.php got corrupted, when I looked at it was just a binary file with all 0s. I replaced it with a fresh copy of the php code from github and now the site is working again!
dipsausDennis replied on at Permalink Reply
I have the same problem and I found a solution. The page isn't loading of the Apache settings (I think). You can fix this problem using the php: ob_start(); function. If you use this function in your file with the error it should work. I hope this will solve future problems.