I have a simple function below to check if the user is already registered on my site. If they are then it doesn't add them and if they aren't it adds them. However In my database for some weird reason a certain user is getting added multiple times with the exact same id. Is there something wrong with mysqli_num_rows?
$check = mysqli_query($con, "SELECT id FROM users WHERE id='$id'");
$row_cnt = mysqli_num_rows($check);
if ($row_cnt == 0) {
$query = "INSERT INTO users (id,username) VALUES ('$id','$username')";
mysqli_query($con, $query);
} else { // If Returned user . update the user record
$query = "UPDATE users SET username='$username' where id='$id'";
mysqli_query($con, $query);
}