php - check if user exists in mysql database and insert non-existing users -
this question has answer here:
i writing php script check if user exists in mysql database , if don't exists. inserted database. keep getting errors of know getting things wrong. can please!!!
$user = 'root'; $pass = ''; $db = 'xxx'; $conn = new mysqli('localhost', $user, $pass, $db) or die("unable connect"); if($signup == "success"){ $conn = new mysqli('localhost', $user, $pass, $db) or die("unable connect"); $sql = "select `rgeratable` (email,phoneno) email=$email , phoneno=$phonenumber"; $result = $conn->query($sql); $rowcount = mysqli_num_rows($result); if($rowcount>=1){ echo "user email: ".$email." , phone number: ".$phonenumber." exists!"; }else{ $sql2 = "insert `rgeratable` (names,email,phoneno,resaddr,passw) values ($name,$email,$phonenumber,$resaddr,$passw)"; $result2 = $conn->query($sql2); if($result2===true){ echo "you have signed up!"; }else{ echo "error, signing up. please try again!"; } } } these errors:
mysqli_num_rows() expects parameter 1 mysqli_result, boolean given on "line in php script". error, signing up. please try again!
Comments
Post a Comment