[code] Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Server\Apache2\htdocs\login2\register.php on line 45 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Server\Apache2\htdocs\login2\register.php on line 46 [/code] these are the errors i get when i use this piece of code however when i take the code out i get no errors what i want to do is add code to my register.php to stop people registering with a username and email address that is already registered. here is my code with the above problems removed maybee that will be more helpfull to you [code] <? include('include/db_connect.php'); $first = $_POST['first']; $last = $_POST['last']; $email = $_POST['email']; $phone = $_POST['phone']; $user = $_POST['user']; $pass = $_POST['pass']; $info = $_POST['info']; $first = stripslashes($first); $last = stripslashes($last); $email = stripslashes($email); $phone = stripslashes($phone); $user = stripslashes($user); $pass = stripslashes($pass); $info = stripslashes($info); if((!$first) || (!$last) || (!$email) || (!$user) || (!$pass)){ echo '<strong>You must fill in all required fields!!!</strong> <br />'; if(!$first){ echo "You must fill in the First Name field! <br />"; } if(!$last){ echo "You must fill in the Last Name field! <br />"; } if(!$email){ echo "You must fill in the E-Mail field! <br />"; } if(!$user){ echo "You must fill in the Username field! <br />"; } if(!$pass){ echo "You must fill in the Password field! <br />"; } include 'register.html'; exit(); } $pass=md5($pass); $sql = mysql_query("INSERT INTO users (first, last, email, phone, user, pass, info) VALUES('$first', '$last', '$email', '$phone', '$user', '$pass', '$info')") or die (mysql_error()); if(!$sql){ echo 'There has been a problem during the registration process please try again later! <br />'; } else{ $userid = mysql_insert_id(); echo 'Your account was created sucsesfully <br />'; } ?> [/code]