Re: General PHP3 problem

From: Date: Thu, 09 Nov 2000 00:16:32 +0000
Subject: Re: General PHP3 problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-24410@lists.php.net to get a copy of this message
On Thu, 09 Nov 2000, Phil Taylor wrote: > I have created "test01.php3" containing the sample script below. However > when I run it the browser displays the following output:- > > > Warning: Cannot add header information - headers already sent by (output > started at /home/taylorp/public_html/test01.php3:2) in > /home/taylorp/public_html/test01.php3 on line 7 > > Warning: Cannot add header information - headers already sent by (output > started at /home/taylorp/public_html/test01.php3:2) in > /home/taylorp/public_html/test01.php3 on line 8 > Authorization Required. > > > Can anyone explain what is happening here? > > Thanks > > Phil > > > > <%php > > if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) > || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'open' ) ) > > > header( 'WWW-Authenticate: Basic realm="Private"' ); > header( 'HTTP/1.0 401 Unauthorized' ); > echo 'Authorization Required.'; > exit; > > } else > > > > echo ' > > <HTML> > <HEAD> > <TITLE>Secret Stuff</TITLE> > </HEAD> > <BODY> > <H1>SECRET!</H1> > <P>This is a secret message.</P> > </BODY> > </HTML> > > '; > > > > } > %> Yes - you are sending white space before the header call. Take the blank lines out of your script before the header lines and try again. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#24410) next »