Conditions within a function

From: Date: Tue, 16 Apr 2002 12:58:37 +0000
Subject: Conditions within a function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93172@lists.php.net to get a copy of this message
I have been trying to organize my code better by using functions, especially where I am repeating logic. The problem seems to be when I run a condition within the function, an if statement to check for results of a variable. As is the code seems to be bypasses, but if I put a die; in the function after the line that was skipped before I get the desired results. Code sample below is checking a table that lists a userID and if the user has ever logged onto the system before: function chkFirstTime($userID){ global $connection,$db,$userID; $sqlChkFirstTime = "select fk_userID,firstTime from firstTime where fk_userID = '$userID'"; $resultFirstTime = mssql_query($sqlChkFirstTime, $connection); $rowFirstTime = mssql_fetch_array($resultFirstTime); $firstTime = $rowFirstTime["firstTime"]; if ($firstTime == ""){ include ('includes/incFirstTime.php'); } } If I place a die; after the include it will run, of course it stops other users from getting in as well. Thanks, -Scott

« previous php.general (#93172) next »