本文介绍了mysqli_fetch_assoc()期望参数1为mysqli_result,布尔值在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
require_once("connect.php");
$login1 = $_POST['email'];
$password1 = $_POST['password'];
$select = "SELECT id FROM loginregistration WHERE login ='$login1', password ='$password1'";
$sql = mysqli_query($con,$select);
$row = mysqli_fetch_assoc($sql);
?>`
我的mysqli_query似乎不起作用,我该怎么办?
it seems that my mysqli_query doesn't work ,what should i do?
推荐答案
在密码附近的查询中使用AND插入逗号(,),这就是查询返回false并抛出该错误的原因
use AND insted of comma (,) in query near password that's why query returning false and throw that error
$select = "SELECT id FROM loginregistration WHERE login ='".$login1."' and password ='".$password1."'";
更新1
如果查询失败,则返回false.所以你可以使用mysqli_error($ con);知道错误
if query fail it return false . so you can use mysqli_error($con); to know the error
<?php
require_once("connect.php");
$login1 = $_POST['email'];
$password1 = $_POST['password'];
$select = "SELECT id FROM loginregistration WHERE login ='".$login1."' AND password ='".$password1."'";
$sql = mysqli_query($con,$select);
if($sql === FALSE) {
die(mysqli_error($con)); // better error handling
}
$row = mysqli_fetch_assoc($sql);
?>
这篇关于mysqli_fetch_assoc()期望参数1为mysqli_result,布尔值在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!