gpt4 book ai didi

php - 警告 : mysqli_fetch_array() expects parameter 1 to be mysqli_result when I have 2 parameters

转载 作者:行者123 更新时间:2023-11-29 04:35:52 25 4
gpt4 key购买 nike

所以我有这个错误:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in C:\wamp\www\Foredeck\login.php on line 101 .

我在互联网上做了一些研究,但仍然不明白错误在哪里。我想我这里有两个参数。那怎么了?

顺便说一句,我是 PHP 新手。

<?php
include("bdconnect_Foredeck.php");
$link = mysqli_connect($host, $login, $pass, $dbname);
$msg = '';

if (isset($_POST['login']) && !empty($_POST['username']) && !empty($_POST['password'])) {

$Identifiant = $_POST["username"];
$MotPasse = $_POST["password"];
$query = "
SELECT *
FROM admin
WHERE identifiant = '$Identifiant'
AND mdp_admin = '$MotPasse'";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($query); //Line 101//

if ($row) {
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$msg = 'Connexion Réussite';

if ($_POST['username'] == 'Isabelle' && $_POST['password'] == 'Isabelle1') {

$_SESSION['username'] = $_row['Identifiant'];
echo "<script type='text/javascript'>alert('Connexion Réussite');
window.location='foredeck_superadmin.php'; </script>";
header("refresh:3 location: foredeck_superadmin.php");

} else {

$_SESSION['username'] = 'foredeckadmin';
echo "<script type='text/javascript'>alert('Connexion Réussite');
window.location='foredeck.php'; </script>";
header("refresh:3 location: foredeck.php");

}

}

} else {
$msg = 'Identifiant ou Mot de Passe incorrecte';
$msg = "<script type='text/javascript'>alert('$msg')</script>";
}
?>

最佳答案

使用 $row=mysqli_fetch_array($result); 代替 $row=mysqli_fetch_array($query);

由于 mysqli_fetch_array() 函数将结果行作为关联数组获取,并且您正在传递类型为 string$query。所以,它的抛出错误。

关于php - 警告 : mysqli_fetch_array() expects parameter 1 to be mysqli_result when I have 2 parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42218748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com