More information about the Underscore mailing list

[_] Error : PHP Warning: Cannot modify header information - headers already sent

Rick Hurst rick.hurst at gmail.com
Mon Mar 19 09:43:13 GMT 2018

Hi Martin

I think others have explained it, but if line 158 is a redirect to the
homepage (presumably wrapped in some logic?), you shouldn't be outputting
any HTML before it. Put that line (and it's logic) at the top, before the
HTML.

Rick

On Mon, Mar 19, 2018 at 9:29 AM, Martin Moore <martinm at it-helps.co.uk>
wrote:

> Turns out I needed ob_start and ob-flush.
>
> The odd thing is it was working at one point....
>
>
> Martin.
>
>
> On 19/03/2018, 00:23, "Underscore on behalf of Jeremy Prior" <
> underscore-bounces at under-score.org.uk on behalf of
> jeremy.prior at blueyonder.co.uk> wrote:
>
>
>
>     > On Mon 19 Mar 2018, at 00:00:37, Martin Moore <
> martinm at it-helps.co.uk> wrote:
>     >
>     > I'm getting a "PHP Warning:  Cannot modify header information -
> headers already sent by (output started at /var/www/codeclink/login/index.php:2)
> in /var/www/codeclink/login/index.php on line 158"
>     >
>     > My understanding is that line 2 is causing problems.
>     >
>     >
>     > This is line 158 :  header('location:home.php');
>     >
>     > I've removed some things but can't work out what's wrong. Even done
> all the stuff Google suggests lol.
>     >
>     > Top of the file:
>     >
>     > <?php session_start(); ?> // THIS IS LINE 1
>     > <html>
>     >   <head>
>
>     I'm not a PHP expert, but I have been bitten by this before.
>
>     Basically, PHP will send whatever headers you tell it to, until you
> send some html.  Once you start sending html, you lose the ability to send
> additional headers.  The `<html>` in line 2 does exactly that.
>
>     https://stackoverflow.com/questions/8028957/how-to-fix-
> headers-already-sent-error-in-php#8028987 has a good explanation of
> this.  It looks like you are falling foul of "2. Raw HTML areas".
>
>     You need to move you line 158 up to the top, or converting the PHP
> redirect into an HTML `META` tag or javascript redirect.
>
>     ʝɛʑ
>     --
>     Jeremy Prior
>
>     --
>     underscore_ list info/archive -> http://www.under-score.org.uk/
> mailman/listinfo/underscore
>
>
> --
> underscore_ list info/archive -> http://www.under-score.org.uk/
> mailman/listinfo/underscore
>



-- 
Rick Hurst
http://www.rickhurst.co.uk