gpt4 book ai didi

php - sql + php - fatal error : Cannot use object of type mysqli_result as array why

转载 作者:行者123 更新时间:2023-12-04 04:46:49 32 4
gpt4 key购买 nike

这是我的代码:

<?php

$con = mysqli_connect("127.0.0.1:3306","root","root","photoshare");
$query = "SELECT ID,nickname,photoLikes FROM tbl_photo";
$result = mysqli_query($con,$query);
$query_dislike = "SELECT nickname, idGivenLike FROM tbl_check_like";
$resultDislike = mysqli_query($con,$query_dislike);
$photoIDdislike;
$photoID;
while($photoID = mysqli_fetch_assoc ($result) || $photoIDdislike = mysqli_fetch_assoc($resultDislike) )
{
//checks if both of results
if($result["ID"] != $resultDislike["idGivenLike"])
{
echo "true";
}
}
?>

当我运行它时,它说下一行
if($result["ID"] != $resultDislike["idGivenLike"])

带有 h fatal error : Fatal error: Cannot use object of type mysqli_result as array
为什么它不起作用,我该如何解决?

最佳答案

if($result["ID"] != $resultDislike["idGivenLike"])

应该:
if($photoID["ID"] != $photoIDdislike["idGivenLike"])
$resultDislike/$result是您的 MySQL 资源, $photoID/$photoIDdislike是获取的行(数组)。

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

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