Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.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 为foreach()提供的参数无效。错误_Php_Foreach_Error Log - Fatal编程技术网

Php 为foreach()提供的参数无效。错误

Php 为foreach()提供的参数无效。错误,php,foreach,error-log,Php,Foreach,Error Log,为foreach()错误提供的参数无效 您好,我的网站有以下问题,当我检查文件“error\u log”时,此em显示以下错误: “为/home/…中的foreach()提供的参数无效” 它位于错误位置: <?php foreach ($on['result'] as $val) { ?> <a href="#" onClick="goToProfile

为foreach()错误提供的参数无效

您好,我的网站有以下问题,当我检查文件“error\u log”时,此em显示以下错误:

“为/home/…中的foreach()提供的参数无效”

它位于错误位置:

  <?php                                       

        foreach ($on['result'] as $val) { ?>

            <a href="#" onClick="goToProfile(<?= $val['id'];?>)"><li class="chat__human" style="margin-bottom: 5px;">

                <img class="chat__avatar" style="padding: 1px;margin:3px" src="<?= $val['photo'];?>" alt="" />

                <span class="chat__name comforta" style="position: absolute;margin-left:5px;margin-top: 5px;font-weight: bold"><?= $val['firstName'];?></span>

                <span class="chat__last_m" style="position: absolute;margin-left:5px;margin-top: 23px;color:#999"> <?= $val['last_m'];?></span>

            </li></a>             

        <?php } ?>        


我希望您能帮我解决这个错误,谢谢。

什么是打印($on['result'])<代码>$on['result']可能未设置或不是数组。如果对$on执行var_dump(),会得到什么?没有,错误仍然存在