By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

"Cannot modify header information" with large HTML FORM options

P: n/a
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

Mar 22 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Chris Robb wrote:
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


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.
js*******@attglobal.net
==================
Mar 22 '06 #2

P: n/a
It's really just a standard for loop:

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

Line 88 is trying to set some cookies:

setcookie("currentYear","$year"); <-----------line 88
setcookie("streetName","$streetName");

-Chris

Mar 22 '06 #3

P: n/a
Chris Robb wrote:
It's really just a standard for loop:

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

Line 88 is trying to set some cookies:

setcookie("currentYear","$year"); <-----------line 88
setcookie("streetName","$streetName");

-Chris


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.
js*******@attglobal.net
==================
Mar 22 '06 #4

P: n/a
On Tue, 21 Mar 2006 23:04:07 -0500, Jerry Stuckle wrote:

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


Probably because of output buffering.

--
http://www.mgogala.com

Mar 22 '06 #5

P: n/a
Moving my cookie set to the top did it. Thanks for the second set of
eyes.

-Chris

Mar 22 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.