Jump to content

Archived

This topic is now archived and is closed to further replies.

KyrinComaBlack

MySQL Problem

Recommended Posts

ok I got it working and everything. Now i'm getting a problem. Ok I created a user and all and it gets put in the table. Then I test out the checking and if says Email is been sent but I just added the same user again :S

heres the code
[code]
$user_check_sql = mysql_query("SELECT username FROM user WHERE username='$username'") or die(mysql_error());
    $email_check_sql = mysql_query("SELECT email_address FROM user WHERE email_address='$email'") or die(mysql_error());

    $user_check = !mysql_fetch_row($user_check_sql);
    $email_check = !mysql_fetch_row($email_check_sql);
    
    if($user_check){
        print("That Username is already takin' please select a new username<br>\n");
    }else{
        if($email_check){
            print("E-Mail is already in use please use a different email<br>\n");
        }else{
            $q = mysql_query("INSERT INTO user (username, password, email_address, city, state, country, gender, month, day, year)
                              VALUES('$username', '$password', '$email', '$city', '$state', '$country', '$gender', '$month', '$day', '$year')");
        }
    }
[/code]

Share this post


Link to post
Share on other sites
Sounds like mysql_fetch_row() isn't returning what you expect -- why not check the actual number of rows with mysql_num_rows() instead?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.