首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >致命错误:第228行,无法将mysqli_result类型的对象用作/home/william/public_html/forums/index.php中的数组

致命错误:第228行,无法将mysqli_result类型的对象用作/home/william/public_html/forums/index.php中的数组
EN

Stack Overflow用户
提问于 2009-07-17 18:56:56
回答 2查看 7.6K关注 0票数 1

为什么这个不起作用?我一直收到这个错误。//设置论坛话题、帖子数、最后一篇文章xxxxx

代码语言:javascript
复制
        $query = array(
            'SELECT'    => 't.subject',
            'FROM'      => 'topics AS t, pbb_forums AS f',
            'WHERE'     => 't.last_post_id = f.last_post_id');

        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

        $forum_page['item_body']['info']['topics'] = '<li class="info-topics"><strong>'.forum_number_format($cur_forum['num_topics']).'</strong> <span class="label">'.(($cur_forum['num_topics'] == 1) ? $lang_index['topic'] : $lang_index['topics']).'</span></li>';
        $forum_page['item_body']['info']['posts'] = '<li class="info-posts"><strong>'.forum_number_format($cur_forum['num_posts']).'</strong> <span class="label">'.(($cur_forum['num_posts'] == 1) ? $lang_index['post'] : $lang_index['posts']).'</span></li>';

        if ($cur_forum['last_post'] != '')
            $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'">'.$result['subject'].'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_forum['last_poster'])).'</cite></li>';
        else
            $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><strong>'.$lang_common['Never'].'</strong></li>';
EN

回答 2

Stack Overflow用户

发布于 2009-07-17 19:10:46

您试图在不调用fetch_array的情况下将mysqli结果($result)用作数组。

无论您使用的是什么框架,都可能为此提供一个包装器。

票数 2
EN

Stack Overflow用户

发布于 2009-07-17 19:11:56

嗯,你似乎有“一些东西”(也许是$result ?)作为对象;并且您将所有内容都用作数组。

也许你有办法将数据作为数组而不是对象来获取?(可能是您正在使用的类的一种方式?)

或者,您需要访问数据作为对象,而不是数组;也许$result->subject,而不是$result'subject‘行吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1145071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档