Re: Solution to "headers already sent" error.

From: Date: Tue, 19 Jun 2001 03:23:43 +0000
Subject: Re: Solution to "headers already sent" error.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-54311@lists.php.net to get a copy of this message
(PHP4) In your php.ini file: output_buffering = On Now you can send header calls and session calls whenever you want. Also, take a look at: http://www.php.net/manual/en/ref.outcontrol.php Ethan ----- Original Message ----- From: "Alexander Wagner" <wagner@globalpark.de> To: <php-general@lists.php.net> Sent: Monday, June 18, 2001 3:54 PM Subject: Re: [PHP] Solution to "headers already sent" error. > Hiho, > > Merio, Quinn wrote: > > So, during the time the lists were down, i was banging my head over a > > seemingly impossible error message. > > > > Warning: Cannot send session cache limiter - headers already sent > > > > What?! I exlaimed.. the first line in my page registered the session > > variable i was using, so what was the deal. I turned out to be one measly > > little space in front of my <?php tag. > > Well, reading the complete message should have helped, which goes like this: > > "Warning: Cannot add header information - headers already sent by (output > started at /foo/foo.php3:2) in /foo/bar.php3 on line 399" > > The message tells you in which file and on which line the output was started. > With PHP 4 it does, anyway. > > > Figured i would share that nugget, cus man did it ever drive me nuts, and i > > saw no reference to it at all in the manuals. > > Not in the session-section, no. But the description of the header()-function > (http://php.net/header) contains this paragraph: > > "Remember that the header() function must be called before any actual output > is sent, either by normal HTML tags blank lines in a file, or from PHP. It is > a very common error to read code with include(), or require(), functions, or > another file access function, and have spaces or empty lines that will output > before header() is called. The same problem exists when using a single > PHP/HTML file." > > Of course, this is hard to find when you're browsing through the > session-functions. A link might be useful. Something like "This function > needs to send a HTTP-Header, so you ... as with the header()-function." > > regards > Wagner > > -- > "Isn't it strange? The same people who laugh at gypsy fortune tellers take > economists seriously." > - Cincinnati Enquirer >

« previous php.general (#54311) next »