答案 0 :(得分:0)
mysql_fetch_array requires a mysqli_result作为第一个参数。您可以获取mysqli_result作为mysqli_query的返回。
例如:
$db = mysqli_connect("localhost","aaron","","demo");
$sql = mysqli_query($db,"SELECT * FROM usres");
$check = mysqli_fetch_array($sql);
还要注意,在SQL语句中直接使用$ _POST ['id'](在您的情况下通过$ id)将对您的应用程序启用SQL注入攻击。有很多不同的方法,其中一种是prepared statements。
答案 1 :(得分:0)
mysqli_fetch_array
仅需要一个由mysqli_query(),mysqli_store_result()或mysqli_use_result()返回的参数。
$sql=mysqli_query($db,"SELECT * FROM usres");
$check=mysqli_fetch_array($sql);//removed $db, which is not needed here
mysqli_fetch_array()函数以关联数组,数字数组或两者兼有的方式获取结果行。
mysqli_fetch_array参数应为:
由mysqli_query(),mysqli_store_result()或mysqli_use_result()返回
答案 2 :(得分:0)
您有错字。在下面的代码中查看注释。
<?php
session_start();
$db=mysqli_connect("localhost","aaron","","demo");
$id = mysqli_real_escape_string($db, $_GET["id"]);
$sql = mysqli_query($db, "SELECT * FROM users"); //You typed usres, but in query below you use users. Your query failed and that's why got the error message.
$check=mysqli_fetch_array($sql);
if(isset($_POST['update'])) {
$id=$_POST['id'];
$name=$_POST['name'];
$email=$_POST['email'];
$password=$_POST['password'];
$bankbookno=$_POST['bankbookno'];
$adharno=$_POST['adharno'];
$pancard=$_POST['pancard'];
$result = mysqli_query($db, "UPDATE users SET name='$name',email='$email',password='$password',bankbookno='$bankbookno' ,adharno='$adharno',pancard='$pancard' WHERE id=$id");
header("location:view.php");
}
?>
您的查询失败,因为您键入了usres
(在更新查询中,您有一个表名users
),这就是为什么您收到有关布尔值的警告的原因。查询返回false,这是布尔值。