[Gllug] phpGroupware

Simon Stewart sms at lateral.net
Wed May 22 13:07:39 UTC 2002


On Wed, May 22, 2002 at 01:25:29PM +0100, Daniel Andersson wrote:
> > On Wed, May 22, 2002 at 12:04:55PM +0100, Daniel Andersson wrote:
> > > > On Wed, May 22, 2002 at 10:29:13AM +0100, Axel Segebrecht wrote:
> > > > >
> > > > > PPS: Here are the errors:
> > > > >
> > > > > Parse error: parse error in
> > > /var/www/groupware.gardeneden.net/header.inc.php
> > > > > on line 38
> > > > >
> > > > > Warning: Cannot add header information - headers already sent by
> (output
> > > > > started at /var/www/groupware.gardeneden.net/header.inc.php:38) in
> > > > > /var/www/groupware.gardeneden.net/setup/index.php on line 24
> > > >
> > > > Turn on output buffering in your php.ini, or check rigourously that no
> > > > white space has been included at the head of one of your display pages
> > > > before the include, or (worse) that there's no white space after the
> > > > closing php tag in any include files. PHP is a stickler for things
> > > > like that.
> > > >
> > > > Basically, the error message says it all: before you've finished
> > > > sending your headers, you've sent some content. Output buffering does
> > > > just that, allowing you to insert random calls to "header()"
> > > > throughout the body of your page.
> > >
> > > well, it can't be any whitespaces SINCE php says "oi, there's an error
> > > here".
> > > THAT'S where the output starts.
> >
> > I believe that you're wrong. The error message is saying that output
> > has already started (on line 38 of header.inc.php) Once _any_ output
> > has been sent, you cannot then send another header, because that's the
> > way that HTTP works. Unless, of course, you use output buffering, that
> > is ;)
> >
> > Looking at the filename, I would suggest that the file is an include
> > that has to be edited to fill in some variable names, and Daniel has
> > simply accidentally added a little bit of space by accident (it's easy
> > enough to do)
> 
> IF php finds an error it outputs something, usually a header and some text.
> "Parse error: parse error in
> /var/www/groupware.gardeneden.net/header.inc.php on line 38"
> in this case.
> 
> that's line 38.
> Warning: Cannot add header information - headers already sent by (output
> started at /var/www/groupware.gardeneden.net/header.inc.php:38) in
> /var/www/groupware.gardeneden.net/setup/index.php on line 24
> 
> do you think it's a coincident that it says "output started at
> /var/www/groupware.gardeneden.net/header.inc.php:38"?
> 
> since the error was on 38, the output will start on 38 as well.
> 
> re-read, re-think and realize ;o)

Okay. I'm only speaking here from experience here rather than some
sort of rigourous proof, so I'll step through this slowly and we'll
draw a conclusion at the end. :)

Consider the error message:

Warning: Cannot add header information - headers already sent by
(output started at
/var/www/groupware.gardeneden.net/header.inc.php:38) in
/var/www/groupware.gardeneden.net/setup/index.php on line 24

The fundamental error is that we "Cannot add header information". This
is because "headers have already been sent". As is well known, an HTTP
request consists of a number of headers, a blank line, and then the
body of the web page. If you try and send another header after this
blank line, then it's an error, a mistake, and, indeed, a bit of a
cock-up.

The PHP manual contains this nugget of information:

"Remember that header() 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 are output before header() is called. The same
problem exists when using a single PHP/HTML file."

(http://uk.php.net/manual/en/function.header.php)

When any output is sent from a script, PHP sends the headers (if not
already sent), adds the blank line and then outputs whatever has just
been outputted (assuming output buffering is not on)

The PHP parser is correctly reporting where the error is, because,
well, that's where the error is. It is not, however, the root cause of
the error. I'd bet a pint that wrapping the offending page with an
"ob_start()" as the very first line, and an "ob_end_flush() as the
very last will remove this error message.

Only the one, mind.

Do you see what I'm driving at here?

Cheers,

Simon

-- 
"People said to me, 'just be youself,' and now they hate me."
    --- Robert Newman, the Mary Whitehouse Experience


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list