PHP执行sql返回不了结果
PHP执行sql返回不了结果<?phpinclude('conn.php');$phone=$_POST['phone'];$check_query="select*fr...
PHP执行sql返回不了结果<?php
include('conn.php');
$phone = $_POST['phone'];
$check_query = "select * from persons where phone='$phone'";
if ($result = mysqli_fetch_array($check_query)) {
session_start();
$_SESSION['phone'] = $phone;
echo "<p>";
echo $phone, ' 成功';
} else {
exit('失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
?>
运行后报错Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in 展开
include('conn.php');
$phone = $_POST['phone'];
$check_query = "select * from persons where phone='$phone'";
if ($result = mysqli_fetch_array($check_query)) {
session_start();
$_SESSION['phone'] = $phone;
echo "<p>";
echo $phone, ' 成功';
} else {
exit('失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
?>
运行后报错Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in 展开
展开全部
你的语句错了 , mysqli_fetch_array() 的参数必须是一个sql 结果集 , 而您给的是一个sql语句字符串。
就是说你缺少 sql 的过程
<?php
include('conn.php');
$phone = $_POST['phone'];
$check_query = "select * from persons where phone='$phone'";
$result=$mysqli->query($check_query); //sql过程
if ($row = $result->fetch_array(MYSQL_ASSOC)) {
session_start();
$_SESSION['phone'] = $row['phone'];
echo "<p>";
echo $phone, ' 成功';
} else {
exit('失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
?>
更多追问追答
追问
还是不行呀 报错Fatal error: Call to a member function query() on null in
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询