I must admit i am relatively new to php $ mysql. Please some suggest me, i want to check for the duplicate entry on my database for two fields usernae and email. My code is executing perfectely for username but not for email . I am not using any primary or unique key on both of them. Below are teh codes : The one that is working for username : /** * Returns true if the username has been taken * by another user, false otherwise. */ function usernameTaken($username){ global $conn; if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "select username from users where username = '$username'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); } And the below for Email check doenn't work : /** * Returns true if the E-Mail has been taken * by another user, false otherwise. */ function emailTaken($email){ global $conn; if(!get_magic_quotes_gpc()){ $email = addslashes($email); } $q = "select E-Mail from users where E-Mail = '$email'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); } Warning that is flashed out for email is : Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in c:\wamp\www\user\register.php on line 31 Please some one suggest me with the code or modifications. Thanks is advance.