致命错误:无法使用类型mysqli_result对象 [英] Fatal error: Cannot use object of type 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$c$c>获取一个结果行作为关联数组。$查询=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
ormysqli_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屋!