else statements not working

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

else statements not working

Post 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
}
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

I don't know but shouldn't there by a If and ElseIf in front of Else?

-Nay
Linkjames
Forum Commoner
Posts: 90
Joined: Tue Sep 16, 2003 8:39 am

Post 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.
Post Reply