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

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

问题描述

我要打开我的网站时,我发现我的MODS的人给我这个错误:


  

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


我就去排队303,这是我发现了什么:

  //检查请求的用户名可以遵循。
如果(in_array($ followingdata ['usergroupid'],爆炸(|,$ vbulletin->选项['subscribetouser_usergroups_cannot']))){

下面是所有code起始于行303:

  //检查请求的用户名可以遵循。
如果(in_array($ followingdata ['usergroupid'],爆炸(|,$ vbulletin->选项['subscribetouser_usergroups_cannot']))){
    出口;
}如果($ followinginfo [订户]&0){
    $ user_followers = $ followinginfo [跟随] $用户信息[用户ID]'|'。;
}
其他{
    。$ user_followers ='|'$用户信息[用户ID]'|';
}$ vbulletin-> DB-GT&; query_write(
    UPDATE。TABLE_ preFIX。用户
    SET用户=用户+ 1'followers` ='$ user_followers
    其中userid = $ followinginfo [用户ID]
);

我不是在PHP代码方面的专家,所以有点帮助会打开网站之前是巨大的。任何帮助/建议?

非常感谢你!


解决方案

  

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


使用 mysqli_fetch_assoc 或<一个href=\"http://www.php.net/manual/en/mysqli-result.fetch-array.php\"><$c$c>mysqli_fetch_array获取一个结果行作为关联数组。

  $查询=SELECT 1;
$结果= $ mysqli-&GT;查询($查询);
$ followingdata = $ result-&GT; FETCH_ASSOC()

  $ followingdata = $ result-&GT; fetch_array(MYSQLI_ASSOC);

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

Fatal error: Cannot use object of type mysqli_result as array in /var/www/vbsubscribetouser.php on line 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']))){

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]
");

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

Thank you very much!

解决方案

Cannot use object of type mysqli_result as 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()

or

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

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

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