Page 1 of 1

else statements not working

Posted: Tue Sep 30, 2003 9:48 am
by Linkjames
The following code should check a username against a database, then check an email address, and if both ok, add the info to the database, but if either of the details are wrong it shows the wrong username message. Help? Cheers -Linkjames

Code: Select all

$namecheck = @mysql_query("SELECT username FROM users WHERE username LIKE '$username'");
if (mysql_num_rows($namecheck) != 0) {
echo 'Sorry username taken';
}
else {

$emailcheck = @mysql_query("SELECT email FROM users WHERE email LIKE '$email'");
if (mysql_num_rows($emailcheck) != 0) {
echo 'Sorry email taken';
}
else {



$result = @mysql_query("INSERT INTO users (username, password, email, verifycode, verifyed ) VALUES ('$username','$passworddata','$email','$verifycode','$verifyed')");


// End email check else
}
// End username check else
}

Posted: Tue Sep 30, 2003 9:51 am
by Nay
I don't know but shouldn't there by a If and ElseIf in front of Else?

-Nay

Posted: Tue Sep 30, 2003 9:52 am
by Linkjames
Ok, weird, it just started working. Guess I must have not saved after my last edit (Although I'm sure I did.) Go figure.