Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MYBB警告[2]count():参数必须是实现可数的数组或对象-行:906_Php_Mybb - Fatal编程技术网

Php MYBB警告[2]count():参数必须是实现可数的数组或对象-行:906

Php MYBB警告[2]count():参数必须是实现可数的数组或对象-行:906,php,mybb,Php,Mybb,您好,抱歉,如果您有疑问,但我不知道如何修复PHP7.24上的MyBB 1.8.15错误 警告[2]count():参数必须是实现可计数的数组或对象-行:906 // Build the threaded post display tree. $query = $db->query(" SELECT p.username, p.uid, p.pid, p.replyto, p.subject, p.dateline FROM ".TABLE_

您好,抱歉,如果您有疑问,但我不知道如何修复PHP7.24上的MyBB 1.8.15错误 警告[2]count():参数必须是实现可计数的数组或对象-行:906

    // Build the threaded post display tree.
    $query = $db->query("
        SELECT p.username, p.uid, p.pid, p.replyto, p.subject, p.dateline
        FROM ".TABLE_PREFIX."posts p
        WHERE p.tid='$tid'
        $visible
        ORDER BY p.dateline
    ");
    while($post = $db->fetch_array($query))
    {
        if(!$postsdone[$post['pid']])
        {
            if($post['pid'] == $mybb->input['pid'] || ($isfirst && !$mybb->input['pid']))
            {
                $postcounter = count($postsdone);
                $isfirst = 0;
            }
            $tree[$post['replyto']][$post['pid']] = $post;
            $postsdone[$post['pid']] = 1;
        }
    }

    $threadedbits = buildtree();
    $posts = build_postbit($showpost);
    eval("\$threadexbox = \"".$templates->get("showthread_threadedbox")."\";");
    $plugins->run_hooks("showthread_threaded");
}

第906行给出错误的是
$postcounter=count($postsdone)

如果$postsdone未计算为“可计数”(在本例中,如果它不是数组),则会发生此错误。我将在执行count($postsdone)之前验证$postsdone是否为数组。例如:

if(is_array($postsdone)){
   $postcounter = count($postsdone);
}
else{
   // set $postcounter to whatever you want it be...
}