gpt4 book ai didi

php - fatal error : Uncaught Error: Cannot use object of type mysqli_result as array with databases

转载 作者:行者123 更新时间:2023-11-29 06:38:51 30 4
gpt4 key购买 nike

我无法弄清楚这里出了什么问题,我正在尝试显示我的数据库结果,但它给了我这个错误,出了什么问题?

<?php
$mysqli = new mysqli("localhost","root","","fakultet");
if ($mysqli->error) {
die("Greska :".$mysqli->error);
}
$upit = "Select * from student WHERE sifra>165";
$rez = mysqli_query($mysqli,$upit);

?>

<html>
<head>
<title></title>
</head>
<body>
<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>BrInd</th>
<th>Prezime</th>
<th>Ime</th>
<th>status</th>
<th>sifra</th>
</tr>

<?php

while ($kokoš=mysqli_fetch_assoc($rez)) {
echo "<tr>";
echo "<td>".$rez['BrInd']."</td>";
echo "<td>".$rez['Prezime']."</td>";
echo "<td>".$rez['Ime']."</td>";
echo "<td>".$rez['status']."</td>";
echo "<td>".$rez['sifra']."</td>";
echo "</tr>";
# code...
}
?>

</table>
</body>
</html>

我不是专家,我只是想学习它,但这让我很头疼。预先非常感谢您!

最佳答案

您已将结果集中的行提取到名为 $kokoš 的变量中,因此该变量包含列数据。

while ($kokoš=mysqli_fetch_assoc($rez)) {
echo "<tr>";
echo "<td>".$kokoš['BrInd']."</td>";
echo "<td>".$kokoš['Prezime']."</td>";
echo "<td>".$kokoš['Ime']."</td>";
echo "<td>".$kokoš['status']."</td>";
echo "<td>".$kokoš['sifra']."</td>";
echo "</tr>";
# code...
}

关于php - fatal error : Uncaught Error: Cannot use object of type mysqli_result as array with databases,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52563536/

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