Hello, Where is $duplicate originally being set? Are you using global variables? is $duplicate being POST'd or GET'd or what?
If it is only gaining it's value from the duplicate_name() function, is that function returning those possible values (1,2) based on whatever the result of the action taken in that fuction is? Maybe try this: if (empty($form["name"])) { $error["name"] = "*"; $message["name"] = "Required field!"; } else { $duplicate = duplicate_name($form["name"]); if ( $duplicate == 0 ) { $error["name"] = "*"; $message["name"] = "Screen name already used!"; } else if ($duplicate == 1) { $error["name"] = "*"; $message["name"] = "Database error - Please try again in a few moments!"; } elseif ($duplicate == 2) { $error["name"] = "*"; $message["name"] = "Server error - Please tryagain in a few moments!"; } else { // not a dup, do whatever } } Nicole @rogers.com> wrote in message news:[EMAIL PROTECTED] > I have a form where the user inputs information - the code below is the > error checking for one of the fields. The first IF statement just checks > that the filed is not empty and works fine. > > Then I check a function I made to see if the user is already in a mysql > database and the function returns 0, 1, or 2 depending on the various > conditions. The first elseif works as I would expect - but it seems that the > next two elseif's are just being ignored. > > Could someone possibly explain what I have wrong here. Thanks > > if (empty($form["name"])) { $error["name"] = "*"; $message["name"] = > "Required field!"; > } > elseif($duplicate = duplicate_name($form["name"]) == 0) { > $error["name"] = "*"; $message["name"] = "Screen name already used!"; > . > } > elseif ($duplicate == 1) { > $error["name"] = "*"; $message["name"] = "Database error - Please try > again in a few moments!"; > } > elseif ($duplicate == 2) { > $error["name"] = "*"; $message["name"] = "Server error - Please try > again in a few moments!"; > } > > > function duplicate_name($name) { > > if (!($connect = @mysql_connect($serverhost,$serveruser,$serverpass))) { > **** These are all defined above but not included here. > $server_error = "2"; > } > if ([EMAIL PROTECTED]($databasename)) { > $server_error = "1"; > } > > if($server_error) { $duplicate = $server_error; > } > else > { > $query = "SELECT name FROM $tablename WHERE name = '$name'"; > > if(!$query) { $duplicate = 1} > > else { > $result = mysql_query($query); > $line = mysql_fetch_array($result); > > if($line['name'] == $name) { $duplicate = 0; } > > mysql_free_result($result); > mysql_close($connect); > > } > } > > echo $duplicate; ***** This shows that the variable $duplicate is > assigned 0, 1, or 2 depending on the what conditions were met. > > return($duplicate); > } > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php