Header() issue..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam

    Header() issue..

    Hello everyone, im trying to connect to a database, and depending on some of
    the variables determine where to redirect the page to.

    However im sure I am not grasping the concept of header(location : url) to
    the fullest.
    And I keept getting the dreaded:

    Warning: Cannot add header information - headers already sent by (output
    started by file.php) on line <line ##>.

    error, so could someone let me know if there is another way to redirect this
    page using PHP, basically of the variable == 1 it goes to pagea.php, if the
    variable ==2 it goes to pageb.php

    Pretty straight forward, and the SQL is all set up properly, just need to
    forward this.

    Thanks!


  • Robert Jirik

    #2
    Re: Header() issue..

    Tuesday 26 of August 2003 22:20, Adam wrote in comp.lang.php:
    [color=blue]
    >
    > Warning: Cannot add header information - headers already sent by (output
    > started by file.php) on line <line ##>.[/color]

    Headers need to be the _first_ output of PHP script - even the PHP
    warning/error messages matter!! So, check if something didn't produce the
    output (it actually did ;) before ...

    regards!

    -robert-

    --
    Robert Jirik
    [mailto:robert(a t)aristoteles(d ot)xhaven(dot)n et]
    public PGP key: http://xhaven.net/robert/pgp_key.asc
    -
    He means well' is useless unless he does well
    -- Plautus

    Comment

    • Adam

      #3
      Re: Header() issue..

      I forgot to mention that there is an include file on line 1.
      And that pages does produce output, is there a way around that??

      Thanks for the quick reply!


      "Robert Jirik" <robert@aristot eles.xhaven.net > wrote in message
      news:biggns$2jg 9$1@news.nextra .cz...[color=blue]
      > Tuesday 26 of August 2003 22:20, Adam wrote in comp.lang.php:
      >[color=green]
      > >
      > > Warning: Cannot add header information - headers already sent by (output
      > > started by file.php) on line <line ##>.[/color]
      >
      > Headers need to be the _first_ output of PHP script - even the PHP
      > warning/error messages matter!! So, check if something didn't produce the
      > output (it actually did ;) before ...
      >
      > regards!
      >
      > -robert-
      >
      > --
      > Robert Jirik
      > [mailto:robert(a t)aristoteles(d ot)xhaven(dot)n et]
      > public PGP key: http://xhaven.net/robert/pgp_key.asc
      > -
      > He means well' is useless unless he does well
      > -- Plautus
      >[/color]


      Comment

      • matty

        #4
        Re: Header() issue..

        Adam wrote:
        [color=blue]
        > I forgot to mention that there is an include file on line 1.
        > And that pages does produce output, is there a way around that??
        >
        > Thanks for the quick reply!
        >[/color]

        If you have the relevant version of PHP, and it's not been disabled in the
        server config, you can put

        ob_start();

        at the beginning of the code, before any output takes place. That will
        let you spit headers out right at the end of the script if you want!

        There's more info on this kind of thing at


        Comment

        • Adam

          #5
          Re: Header() issue..

          Thanks Matty, ill get looking at that right away!



          "matty" <matt+nntp@askm enoquestions.co .uk> wrote in message
          news:JmR2b.4$4L 1.882@wards.for ce9.net...[color=blue]
          > Adam wrote:
          >[color=green]
          > > I forgot to mention that there is an include file on line 1.
          > > And that pages does produce output, is there a way around that??
          > >
          > > Thanks for the quick reply!
          > >[/color]
          >
          > If you have the relevant version of PHP, and it's not been disabled in the
          > server config, you can put
          >
          > ob_start();
          >
          > at the beginning of the code, before any output takes place. That will
          > let you spit headers out right at the end of the script if you want!
          >
          > There's more info on this kind of thing at
          > http://www.php.net/manual/en/ref.outcontrol.php
          >[/color]


          Comment

          Working...