mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in when php queries the database
<?php include "../common/dbsession.php"; session_start(); if(isset($_SESSION['user'])){ header('location:../content/home.php'); }else{ if(isset($_POST['vcode'])){ if($_POST['vcode']==$_SESSION['vcode']){ //核对数据表user $conn=mysqli_connect("10.21.54.99:3306","c322","20210409","c322"); $sql="select * from `user` where `email`='".$_POST['zh']."'"; $res=mysqli_query($conn,$sql); mysqli_fetch_array($res); /*if (!$res){ printf("Error: %s\n", mysqli_error($conn)); exit(); }*/ $row=mysqli_fetch_assoc($res); if(!$conn){ die("连接失败".mysqli_connect_error()); } //var_dump($res); if(isset($row['pw'])){//表中存在 if(md5($_POST['pw'])==$row['pw']){ $_SESSION=[]; $_SESSION['user']=$_POST['zh']; //登陆成功 echo "3"; }else{ echo "0";//账户密码错误 } }else{ //表中不存在 echo "2";//账户不存在 } }else{ echo "1";//验证码不对 //session_destroy(); } exit; } }?><!doctype html><html> <head> <title>User login</title> <meta charset="utf-8"> <script type="text/javascript" src="//m.sbmmt.com/global/wenda/../resource/jquery-3.2.1.min.js"></script> <link rel="style.css" href="//m.sbmmt.com/global/wenda/../login.css"> </ head> <body> <div style="text-align:center;margin-top:20px;"> <div>Welcome to log in</div> <form action='' method='post' > /div> ="pw" placeholder="Please enter password" autocomplete="off" > </div> </form> ".vcode").val(), "zh":$( ".zh").val(), "pw":$(".pw").val()}, function(res){ alert(res); alert(res); if(res==0){ window.location.href "../content/home.php"; alert(" Account input error, please re -enter! ");} Else if (res == 3) {alert (" Account password input error, please re -enter! "); Or contact the administrator!") lt;/body></html>
1 answers
if (!$res) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
Do not comment this statement to see if it is a mysqli_fetch_assoc() parameter problem or a sql statement problem
Thank you, boss. I have it. I have two lines of code with multiple symbols.
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20417
7
13577
4






