headers already sent ...

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

    headers already sent ...

    My host doesn't use buffering so I placed the form validation (php) ahead of
    the html like this:

    <?php
    if(isset($_POST['dn])) {
    <do the validation processing>
    if(file_exists( $fn)) {
    header("Locatio n: $fn"); <---Bombs
    }
    }
    include('./dlheader.inc'); // this provides the <HEAD> html script
    ?>
    <form name="form1" method="post" action=<?php echo $_SERVER['PHP_SELF']; ?>"
    ......
    The script works good on my machine with Apache/PHP, but on the host which
    uses Apache/PHP, it states that the headers have already been sent (when it
    gets to <---Bombs header). I can't understand it. Any help on this would
    certainly be appreciated.




  • Kevin

    #2
    Re: headers already sent ...

    Is there anything before the <?php at the start of the document? A single
    line feed or space would be considered content and sent to the client before
    your header.

    - Kevin

    "Douglas F." <rastor@nospami com.net> wrote in message
    news:1103647001 .3947e812e85d4e 3bc44883eda231d 879@teranews...[color=blue]
    > My host doesn't use buffering so I placed the form validation (php) ahead
    > of
    > the html like this:
    >
    > <?php
    > if(isset($_POST['dn])) {
    > <do the validation processing>
    > if(file_exists( $fn)) {
    > header("Locatio n: $fn"); <---Bombs
    > }
    > }
    > include('./dlheader.inc'); // this provides the <HEAD> html script
    > ?>
    > <form name="form1" method="post" action=<?php echo $_SERVER['PHP_SELF'];
    > ?>"
    > .....
    > The script works good on my machine with Apache/PHP, but on the host which
    > uses Apache/PHP, it states that the headers have already been sent (when
    > it
    > gets to <---Bombs header). I can't understand it. Any help on this would
    > certainly be appreciated.
    >
    >
    >
    >[/color]


    Comment

    • Andy Hassall

      #3
      Re: headers already sent ...

      On Tue, 21 Dec 2004 11:38:54 -0500, "Douglas F." <rastor@nospami com.net> wrote:
      [color=blue]
      >My host doesn't use buffering so I placed the form validation (php) ahead of
      >the html like this:
      >
      ><?php
      >if(isset($_POS T['dn])) {
      > <do the validation processing>
      > if(file_exists( $fn)) {
      > header("Locatio n: $fn"); <---Bombs
      > }
      >}
      >include('./dlheader.inc'); // this provides the <HEAD> html script
      >?>
      ><form name="form1" method="post" action=<?php echo $_SERVER['PHP_SELF']; ?>"
      >.....
      >The script works good on my machine with Apache/PHP, but on the host which
      >uses Apache/PHP, it states that the headers have already been sent (when it
      >gets to <---Bombs header). I can't understand it. Any help on this would
      >certainly be appreciated.[/color]

      What's the full error message? It tells you what line started the output that
      caused headers to be sent.

      For example:

      Warning: Cannot modify header information - headers already sent by (output
      started at /home/andyh/public_html/test.php:2)

      (Generally you should always post the exact text of errors rather than
      paraphrasing them)

      --
      Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      • Douglas F.

        #4
        Re: headers already sent ...

        Cannot modify header information, headers already sent by(output started at
        /home/../download.php.2) in /home/../download.php on line 82

        "Andy Hassall" <andy@andyh.co. uk> wrote in message
        news:76lgs0pbkc c4re6vgtcdcg1hs 95490ku5c@4ax.c om...[color=blue]
        > On Tue, 21 Dec 2004 11:38:54 -0500, "Douglas F." <rastor@nospami com.net>[/color]
        wrote:[color=blue]
        >[color=green]
        > >My host doesn't use buffering so I placed the form validation (php) ahead[/color][/color]
        of[color=blue][color=green]
        > >the html like this:
        > >
        > ><?php
        > >if(isset($_POS T['dn])) {
        > > <do the validation processing>
        > > if(file_exists( $fn)) {
        > > header("Locatio n: $fn"); <---Bombs
        > > }
        > >}
        > >include('./dlheader.inc'); // this provides the <HEAD> html script
        > >?>
        > ><form name="form1" method="post" action=<?php echo $_SERVER['PHP_SELF'];[/color][/color]
        ?>"[color=blue][color=green]
        > >.....
        > >The script works good on my machine with Apache/PHP, but on the host[/color][/color]
        which[color=blue][color=green]
        > >uses Apache/PHP, it states that the headers have already been sent (when[/color][/color]
        it[color=blue][color=green]
        > >gets to <---Bombs header). I can't understand it. Any help on this[/color][/color]
        would[color=blue][color=green]
        > >certainly be appreciated.[/color]
        >
        > What's the full error message? It tells you what line started the output[/color]
        that[color=blue]
        > caused headers to be sent.
        >
        > For example:
        >
        > Warning: Cannot modify header information - headers already sent by[/color]
        (output[color=blue]
        > started at /home/andyh/public_html/test.php:2)
        >
        > (Generally you should always post the exact text of errors rather than
        > paraphrasing them)
        >
        > --
        > Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
        > <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool[/color]


        Comment

        • Andy Hassall

          #5
          Re: headers already sent ...

          On Tue, 21 Dec 2004 12:27:17 -0500, "Douglas F." <rastor@nospami com.net> wrote:
          [color=blue]
          >"Andy Hassall" <andy@andyh.co. uk> wrote in message
          >news:76lgs0pbk cc4re6vgtcdcg1h s95490ku5c@4ax. com...[color=green]
          >> On Tue, 21 Dec 2004 11:38:54 -0500, "Douglas F." <rastor@nospami com.net>[/color]
          >wrote:[color=green]
          >>[color=darkred]
          >>><?php
          >>>if(isset($_P OST['dn])) {
          >>> <do the validation processing>
          >>> if(file_exists( $fn)) {
          >>> header("Locatio n: $fn"); <---Bombs
          >>> }
          >>>}
          >>>
          >>>The script works good on my machine with Apache/PHP, but on the host
          >>>which uses Apache/PHP, it states that the headers have already been sent (when
          >>>it gets to <---Bombs header). I can't understand it. Any help on this
          >>>would certainly be appreciated.[/color]
          >>
          >> What's the full error message? It tells you what line started the output
          >> that caused headers to be sent.[/color]
          >
          >Cannot modify header information, headers already sent by(output started at
          >/home/../download.php.2) in /home/../download.php on line 82[/color]

          OK, then what's on line 2 of the real code you're running? (The code you
          posted wouldn't even parse, particularly line 2).

          --
          Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
          <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

          Comment

          • Douglas F.

            #6
            Re: headers already sent ...

            I'll be darn. I deleted the blank space above <?php and it worked. I guess
            you were right about no blank spaces above the code. It didn't occur to me
            that something like that would cause something to hang. Usually, all blanks
            are parsed out in compilers, etc.. Thanks a lot.

            "Kevin" <kevin@wxREMOVE 4SPAM3.com> wrote in message
            news:4nYxd.2674 76$HA.55784@att bi_s01...[color=blue]
            > Is there anything before the <?php at the start of the document? A single
            > line feed or space would be considered content and sent to the client[/color]
            before[color=blue]
            > your header.
            >
            > - Kevin
            >
            > "Douglas F." <rastor@nospami com.net> wrote in message
            > news:1103647001 .3947e812e85d4e 3bc44883eda231d 879@teranews...[color=green]
            > > My host doesn't use buffering so I placed the form validation (php)[/color][/color]
            ahead[color=blue][color=green]
            > > of
            > > the html like this:
            > >
            > > <?php
            > > if(isset($_POST['dn])) {
            > > <do the validation processing>
            > > if(file_exists( $fn)) {
            > > header("Locatio n: $fn"); <---Bombs
            > > }
            > > }
            > > include('./dlheader.inc'); // this provides the <HEAD> html script
            > > ?>
            > > <form name="form1" method="post" action=<?php echo $_SERVER['PHP_SELF'];
            > > ?>"
            > > .....
            > > The script works good on my machine with Apache/PHP, but on the host[/color][/color]
            which[color=blue][color=green]
            > > uses Apache/PHP, it states that the headers have already been sent (when
            > > it
            > > gets to <---Bombs header). I can't understand it. Any help on this[/color][/color]
            would[color=blue][color=green]
            > > certainly be appreciated.
            > >
            > >
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Michael Fesser

              #7
              Re: headers already sent ...

              .oO(Douglas F.)
              [color=blue]
              >I'll be darn. I deleted the blank space above <?php and it worked. I guess
              >you were right about no blank spaces above the code. It didn't occur to me
              >that something like that would cause something to hang. Usually, all blanks
              >are parsed out in compilers, etc.. Thanks a lot.[/color]

              That's simply the way it works. Everything(!) outside a <?php ... ?>
              block is sent as-is to the client. After all that's what makes it
              possible to embed PHP into a HTML document. But sending content back to
              the client requires to send the headers first ...

              Micha

              Comment

              Working...