致命错误:无法使用mysqli_result类型的对象

Ser*_*ncu 10 php arrays mysqli

当我注意到我的一个mod给了我这个错误时,我即将打开我的网站:

致命错误:不能在第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']))){
Run Code Online (Sandbox Code Playgroud)

以下是从第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]
");
Run Code Online (Sandbox Code Playgroud)

我不是php编码的专家,所以在打开网站之前会有一些帮助.任何帮助/建议?

非常感谢你!

Ker*_*mit 28

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

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

$query = "SELECT 1";
$result = $mysqli->query($query);
$followingdata = $result->fetch_assoc()
Run Code Online (Sandbox Code Playgroud)

要么

$followingdata = $result->fetch_array(MYSQLI_ASSOC);
Run Code Online (Sandbox Code Playgroud)