我正在尝试通过表单提交数据并遇到以下错误:
警告:
mysql_num_rows()
期望参数1为资源,布尔值为..
请找到我尝试的代码。
//connection end to my data server.
if(isset($_POST["submit"])) {
$user_name = $_POST['name'];
$user_email = $_POST['email'];
$user_skype = $_POST['skype'];
if($user_name==""){
echo "<script>alert('please enter your user name!')</script>";
exit();
}
if($user_email==""){
echo "<script>alert('please enter your email!')</script>";
exit();
}
if($user_skype==""){
echo "<script>alert('please enter your skype id.')</script>";
exit();
}
$check_email = "select * from binary where user_email = '$user_email' ";
$run = mysql_query($check_email);
if(mysql_num_rows($run)>0){
echo "<script>alert('Your email $user_email address already exist. please try another.')</script>";
exit();
}
$query= "insert into binary (user_name, user_email, user_skype) values('$user_name','$user_email','$user_skype')";
if(mysql_query($query)){
echo "<script>window.open('success.html','_self')</script>";
}
}
?>
答案 0 :(得分:1)
二进制为sql reserrve word
在其周围使用反对
$check_email = "select * from `binary` where user_email = '$user_email' ";
检查此链接是否有sql reserve word。 http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
并学习 mysqli _ 功能或 P.D.O ,因为mysql是deprcitaeted
答案 1 :(得分:0)
请更新您的查询: 它应该是
$check_email = "select * from `binary` where user_email = '".$user_email."' ";
答案 2 :(得分:0)
似乎select查询返回布尔值false,因为
$check_email = "select * from binary where user_email = '$user_email' "
其中user_email = '$user_email'
无法解析'$user_email'
的值,因为单个quat中的变量未使用其值进行解析
使用: - 其中user_email =&#34;。$ user_email; 一切都应该有效