Failed to start the session because headers have already been sent

Permalink
I've just tried moving a site to my customer's webhost. However, I get the below error when I try to call the site.

Failed to start the session because headers have already been sent by "../application/config/database.php" at line 1.


Has anyone else experienced this and knows how to solve it?

(When I try to run a new install on this webhost, the environment checker tells me to disable PHP's ASP Style Tags. Will look into this now...)

 
JohntheFish replied on at Permalink Reply
JohntheFish
There has been a php warning or error output very early on in the request, before the session was handled. If you do a right click and view source in your browser (view source, not the developer console) you will probably see the error report right at the top of the raw source.
publicb replied on at Permalink Reply
Just ran into this message again, this time after changing database.php.

- Client has cancelled a domain name
- Database.php pointed to said domain name

<?php
return array(
    'default-connection' => 'concrete',
    'connections' => array(
        'concrete' => array(
            'driver' => 'c5_pdo_mysql',
            'server' => 'mysql5.olddomain.biz',
            'database' => 'dbuser',
            'username' => 'dbuser',
            'password' => '*****',
            'charset' => 'utf8',
        ),
    ),
);


- changed database.php ('server') to point to the correct name

<?php
return array(
    'default-connection' => 'concrete',
    'connections' => array(
        'concrete' => array(
            'driver' => 'c5_pdo_mysql',
            'server' => 'mysql5.newdomain.de',
            'database' => 'dbuser',
            'username' => 'dbuser',
            'password' => '*****',
            'charset' => 'utf8',
        ),
    ),
);


- now get the following message

An unexpected error occurred.
Failed to start the session because headers have already been sent by "/application/config/database.php" at line 1.


Anyone else experienced this? How do you deal with it?
publicb replied on at Permalink Reply
Problem was caused by a faulty encoding of the database.php file. My FileZilla was configured to use LibreOffice Writer as its default editor. This somehow messed up the encoding. Ouch.

Anyway, I checked the encoding with Sublime Text (run view.encoding() in the console). It was set to 'UTF-8 with BOM'.

After saving the file with plain 'UTF-8' encoding and reuploading it, the site became accessible again.

Thanks to @daenu for pointing this out!