"Cannot modify header information" with large HTML FORM options

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

    "Cannot modify header information" with large HTML FORM options

    I'm having some really odd behavior with a PHP script. I have it
    populating an HTML select form with a for loop. When I try the years
    2006 to 1900. I get the following error:

    PHP Warning: Cannot modify header information - headers already sent
    by (output started at
    /Users/chrobb/Sites/city-directory/controlBar.php: 54) in
    /Users/chrobb/Sites/city-directory/controlBar.php on line 88

    I've done a fair amount of searching and it looks like this usually
    shows up when people have some extra whitespace after their closing PHP
    tags. Doesn't apply seem to apply here. When I crank the number down on
    the for loop to 94 iterations, the error goes away. Once I crank it up
    to 95, the error comes into play. So, it's tied to the output somehow.
    Looking at the raw HTML, there doesn't appear to be any significant
    difference between the version with 94 iterations versus the one with
    95 iterations, except for the error and the failure of my script.

    Anyone have any ideas? I'm tapped out.

    -Chris

  • Jerry Stuckle

    #2
    Re: "Cannot modify header information&quo t; with large HTML FORM options

    Chris Robb wrote:[color=blue]
    > I'm having some really odd behavior with a PHP script. I have it
    > populating an HTML select form with a for loop. When I try the years
    > 2006 to 1900. I get the following error:
    >
    > PHP Warning: Cannot modify header information - headers already sent
    > by (output started at
    > /Users/chrobb/Sites/city-directory/controlBar.php: 54) in
    > /Users/chrobb/Sites/city-directory/controlBar.php on line 88
    >
    > I've done a fair amount of searching and it looks like this usually
    > shows up when people have some extra whitespace after their closing PHP
    > tags. Doesn't apply seem to apply here. When I crank the number down on
    > the for loop to 94 iterations, the error goes away. Once I crank it up
    > to 95, the error comes into play. So, it's tied to the output somehow.
    > Looking at the raw HTML, there doesn't appear to be any significant
    > difference between the version with 94 iterations versus the one with
    > 95 iterations, except for the error and the failure of my script.
    >
    > Anyone have any ideas? I'm tapped out.
    >
    > -Chris
    >[/color]

    Sorry, my crystal ball isn't working tonight. I can't tell what might
    be happening without seeing some code.

    But it looks like it tried to send header information on line 88 but
    output had already been sent on line 54.


    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Chris Robb

      #3
      Re: "Cannot modify header information&quo t; with large HTML FORM options

      It's really just a standard for loop:

      for ($j=0; $j <93; $j++) {
      echo "<OPTION VALUE='blah'>bl ah</OPTION>"; <---line 54
      }

      Line 88 is trying to set some cookies:

      setcookie("curr entYear","$year "); <-----------line 88
      setcookie("stre etName","$stree tName");

      -Chris

      Comment

      • Jerry Stuckle

        #4
        Re: &quot;Cannot modify header information&quo t; with large HTML FORM options

        Chris Robb wrote:[color=blue]
        > It's really just a standard for loop:
        >
        > for ($j=0; $j <93; $j++) {
        > echo "<OPTION VALUE='blah'>bl ah</OPTION>"; <---line 54
        > }
        >
        > Line 88 is trying to set some cookies:
        >
        > setcookie("curr entYear","$year "); <-----------line 88
        > setcookie("stre etName","$stree tName");
        >
        > -Chris
        >[/color]

        You can't set cookies after you've sent ANY output to the browser!

        The question isn't why it fails after 94 iterations. The question is
        why it works with 93 iterations.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Mladen Gogala

          #5
          Re: &quot;Cannot modify header information&quo t; with large HTML FORM options

          On Tue, 21 Mar 2006 23:04:07 -0500, Jerry Stuckle wrote:
          [color=blue]
          >
          > The question isn't why it fails after 94 iterations. The question is
          > why it works with 93 iterations.[/color]

          Probably because of output buffering.

          --


          Comment

          • Chris Robb

            #6
            Re: &quot;Cannot modify header information&quo t; with large HTML FORM options

            Moving my cookie set to the top did it. Thanks for the second set of
            eyes.

            -Chris

            Comment

            Working...