Abnormal behaviour with php

From: Date: Fri, 01 Mar 2002 06:15:59 +0000
Subject: Abnormal behaviour with php
Groups: php.general 
Request: Send a blank email to php-general+get-86720@lists.php.net to get a copy of this message
Hi , It z amazing behaviour...I am wondering how it is coming only for first time execution. If I remove the two If conditions in authentication.php and if I execute then it is displaying the blank screen. And again if we replace those two if conditions and if you execute again then it works fine. Details are below: I have a login page where we enter login details..And I post these details to authentication.php After system rebooting if I execute first time it is giving alert with message Program Error "php.exe has generated errors and will be closed by windows. You will need to restart the program. An error log is being created. OK " Login.html ========== post emp_id and password to authentication.php Authentication.php ================== <?php // Connect to MySQL $connection=mysql_connect( 'localhost', 'balaji', 'pingpong' ) or die ( 'Unable to connect to server.' ); // Select database on MySQL server mysql_select_db( 'amerm' ) or die ( 'Unable to select database.' ); // Formulate the query $sql = "SELECT * FROM employee WHERE emp_id = '$emp_id' AND emp_pass = PASSWORD('$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 ) { $row = mysql_fetch_object($result); // A matching row was found - the user is authenticated. //start a new session by registering the employee number. session_start(); session_register("user","pw","usertype"); $user=$emp_id; $pw =$emp_pass; $usertype=$row->user_type; //This is the precious code. If we remove these two conditions and if you run once. Then it shows blank. //And if you run second time withese two conditions it works fine. if ($row->user_type=='S') { //close mysql connection mysql_close($connection); header("Location: admin.php"); exit; } else if ($row->user_type=='U') { //close mysql connection mysql_close($connection); header ("Location: user.php"); exit; } } else { //close mysql connection mysql_close($connection); //User does not exist or not authenticated. header("Location:not_authorized.html"); exit; } ?> How can I overcome this problem. Thanks in advance. Regards Balaji

**************************Disclaimer************************************ Information contained in this E-MAIL being proprietary to Wipro Limited is 'privileged' and 'confidential' and intended for use only by the individual or entity to which it is addressed. You are notified that any use, copying or dissemination of the information contained in the E-MAIL in any manner whatsoever is strictly prohibited. ********************************************************************
« previous php.general (#86720) next »