致命错误:无法使用 mysqli_result 类型的对象 [英] Fatal error: Cannot use object of type mysqli_result

查看:47
本文介绍了致命错误:无法使用 mysqli_result 类型的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我注意到我的一个模组给我这个错误时,我正准备打开我的网站:

I'm about to open my website when I noticed that one of my mods gives me this error:

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

Fatal error: Cannot use object of type mysqli_result as array in /var/www/vbsubscribetouser.php on line 303

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

I've went to line 303 and this is what I found:

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

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

Here is all the code starting at line 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 编码方面的专家,所以在打开网站之前获得一些帮助会很好.有什么帮助/建议吗?

I'm not an expert in php coding, so a bit of help would be great before opening the website. Any help/suggestions?

非常感谢!

推荐答案

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

Cannot use object of type mysqli_result as array

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

Use mysqli_fetch_assoc or mysqli_fetch_array to fetch a result row as an associative array.

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

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

这篇关于致命错误:无法使用 mysqli_result 类型的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆