错误:
警告:mysql_query()要求参数1为字符串,对象在第20行的C:\ xampp \ htdocs \ social_network \ functions \ functions.php中给出
警告:mysql_num_rows()期望参数1为资源,在第21行的C:\ xampp \ htdocs \ social_network \ functions \ functions.php中给出null
我正在使用连接:
$ con = mysqli_connect(" localhost"," root",""," social_network")或死亡(&#34 ;连接未建立");
代码:
function InsertUser(){
global $con;
if(isset ($_POST['sign_up'])){
$name = $_POST['u_name'];
$psss = $_POST['u_pass'];
$email = $_POST['u_email'];
$country = $_POST['u_country'];
$gender = $_POST['u_gender'];
$b_day = $_POST['u_birthday'];
$name = $_POST['u_name'];
$date = date("d-m-y");
$status = "unverified";
$posts = "No";
$get_email = "select * from users where user_email='$email'";
$run_email = mysql_query($con,$get_email);
$check = mysql_num_rows($run_email);
if($check==1){
echo "<script>alert ('Email is already registered, please try another one!')</script>";
exit();
}
}
}
?>
答案 0 :(得分:0)
$run_email = mysql_query($get_email,$con);
FYI mysql驱动程序已被弃用,您必须使用mysqli或PDO。