Re: plz check the warning message

From: Date: Mon, 13 Aug 2001 08:34:15 +0000
Subject: Re: plz check the warning message
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-62387@lists.php.net to get a copy of this message
On Mon, Aug 13, 2001 at 02:01:59PM +0530, Balaji Ankem wrote: > Hi! Renze, > Thanks a lot for u'r help. I am in vacation up to now. > Now i am trying with u'r solution. I am getting the following error. > I am sending the file also. > > Warning: Cannot send session cache limiter - headers already sent in c:\www\authentication.php > on line 34 > > > File:authentication.php > <?php > header ("Cache-Control: no-cache, must-revalidate"); > header ("Pragma: no-cache"); > > error_log ("emp_id: $emp_id", 0); > error_log ("Lastname: $emp_pass", 0); > > // Connect to MySQL > > mysql_connect( 'localhost', 'balaji', 'pingpong' ) > or die ( 'Unable to connect to server.' ); > > // Select database on MySQL server > > mysql_select_db( 'imac' ) > or die ( 'Unable to select database.' ); > > // Formulate the query > > $sql = "SELECT * FROM employee WHERE > emp_id = '$emp_id' AND emp_pass = '$emp_pass'"; > > // Execute the query and put results in $result > > $result = mysql_query( $sql ) > or die ( 'Unable to execute query.' ); > > // Get number of rows in $result. > > $num = mysql_numrows( $result ); > > if ( $num != 0 ) { > // A matching row was found - the user is authenticated. > session_start(); > session_register('$emp_id'); > > $row = mysql_fetch_object($result); > > if ($row->user_type=='S') > { > include('super.php'); > > } > else if ($row->user_type=='O') > { > include('ordinary.php'); > > } > } > > else > { > file://User does not exist or not authenticated. > echo '<center><h1>Authorization Required.</h1></center>'; > file://header( 'WWW-Authenticate: Basic realm="Private"' ); > file://header( 'HTTP/1.0 401 Unauthorized' ); > exit; > } > > ?> Well... You can't sent any headers after some output has already been sent. I didn't take a very good look at your code, but looking at the warning you get and the position of session_start() in your code, I'd say you have to move the session_start() up. You can best start your code with session_start() and then the rest of your script. -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- H: +31 23 5516190 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#62387) next »