【发布时间】:2016-09-24 14:11:00
【问题描述】:
错误:
警告:mysql_query() 期望参数 1 是字符串,对象在 C:\xampp\htdocs\social_network\functions\functions.php 第 20 行给出
警告:mysql_num_rows() 期望参数 1 是资源,在第 21 行的 C:\xampp\htdocs\social_network\functions\functions.php 中给出 null
我正在使用 连接:
$con = mysqli_connect("localhost","root","","social_network") 或 die("连接未建立");
代码:
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();
}
}
}
?>
【问题讨论】:
-
你需要调试你的代码。 1.
var_dump($con)在你的函数中检查你得到的值。 2.使用mysql_error()函数>>$run_email = mysql_query($con,$get_email); or die(mysql_error()) -
不知道您使用哪个 API 进行连接。
-
$con = mysqli_connect("localhost","root","","social_network") 或 die("连接未建立");
-
请务必花时间阅读有关给定 MySQL API 的手册。您对“ADHD 和阅读障碍” 的看法简直是垃圾。不久前我也看到过同样的帖子。多动症和阅读障碍不是借口。我也有阅读障碍的案例(事实),这从未阻止我使用正确的语法。
标签: php