include("lib/config.php");
include("lib/mysql.php");
if ($_GET['action'] == "loginsignup") {
$error = "";
if(!$_POST['email']) {
$error = "an email address is needed";
} else if(!$_POST['password']) {
$error = "a password is needed";
} else if (filter_var($_POST['email'],FILTER_VALIDATE_EMAIL) === false) {
$error = "please enter a valid email address";
}
if ($error != "") {
echo $error;
exit();
}
if($_POST['loginactive'] == "0") {
$query = "SELECT * FROM 'users' WHERE email = '".mysql_real_escape_string($link, $_POST['email'])."' LIMIT 1 ";
$result = mysql_query($link,$query);
if(mysql_num_rows($result) == 0) $error = "that email address is already taken.";
}
if ($error != "") {
echo $error;
exit();
}
}
所以这里是代码我试图验证是否有任何错误,如果我的数据库中有一个电子邮件,其中有一个已注册的电子邮件,所以我得到这些错误
mysql_real_escape_string()
期望参数1为字符串,资源为
mysql_query()
期望参数1为字符串,资源在
mysql_num_rows()
期望参数1在
我真的尝试使用mysqli和mysql来回和他们都有相同的错误
答案 0 :(得分:0)
你作为参数传递一个变量,该变量被声明或初始化为mysql_real_escape_string(),这导致它返回一个意外的结果,导致mysql_query()& mysql_num_rows()没有收到预期的参数。
希望它有所帮助!