Problem with MYSQL Query

trakstarz

New Member
Jul 21, 2011
14
0
My hotel is private, so whenever a user registers on my site, they have to enter a registration code (similar to a referral code), that they obtained from a friend.

In order to validate the code exists in my database, i would like to check the following tables based on the user input:

Database table: USERS
Rows: Code, Username, (or) Real_name

The reason why it needs to check if Username (OR) Real_Name exists is because the code that the new user enters in my site must be matched to their friends username/real_name.
Below, i put the code that i tried using but wouldn't work:

Source: class.users.php
PHP:
public function IsCodeExist($code = '')
    {
        if (mysql_num_rows(dbquery("SELECT * FROM users WHERE register_code = '" . $code . "' AND (username = '" . $fname . "' OR real_name = '" . $fname . "')")))
            return true;

        return false;
    }

Can anybody provide me with a working code? thanks in advance
 

Users who are viewing this thread

Top