【问题标题】:Fatal error: Cannot use object of type mysqli_result [closed]致命错误:无法使用 mysqli_result 类型的对象 [关闭]
【发布时间】:2013-05-07 16:26:54
【问题描述】:

我正要打开我的网站时发现我的一个模组给了我这个错误:

致命错误:无法在第 303 行的 /var/www/vbsubscribetouser.php 中使用类型为 mysqli_result 的对象作为数组

我去了第 303 行,这就是我发现的:

//Check if requested username can be followed.
if (in_array($followingdata['usergroupid'], explode("|", $vbulletin->options['subscribetouser_usergroups_cannot']))){

这是从第 303 行开始的所有代码:

//Check if requested username can be followed.
if (in_array($followingdata['usergroupid'], explode("|", $vbulletin->options['subscribetouser_usergroups_cannot']))){
    exit;
}

if ($followinginfo[subscribers] > 0){
    $user_followers = $followinginfo[followers].$userinfo[userid].'|';
}
else{
    $user_followers = '|'.$userinfo[userid].'|';
}

$vbulletin->db->query_write("
    UPDATE " . TABLE_PREFIX . "user
    SET subscribers = subscribers + 1, `followers` = '$user_followers'
    WHERE userid = $followinginfo[userid]
");

我不是 php 编码方面的专家,所以在打开网站之前获得一些帮助会很有帮助。有什么帮助/建议吗?

非常感谢!

【问题讨论】:

    标签: php arrays mysqli


    【解决方案1】:

    不能使用 mysqli_result 类型的对象作为数组

    使用mysqli_fetch_assocmysqli_fetch_array 获取结果行作为关联数组。

    $query = "SELECT 1";
    $result = $mysqli->query($query);
    $followingdata = $result->fetch_assoc()
    

    $followingdata = $result->fetch_array(MYSQLI_ASSOC);
    

    【讨论】:

      猜你喜欢
      • 2013-07-27
      • 2017-11-12
      • 1970-01-01
      • 2019-03-04
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多