开发者

Invalid argument supplied for foreach() codeigniter

Am getting the error in the code igniter view page as

Invalid argument supplied for foreach() codeigniter in the following co开发者_Python百科de;

<html>
<head>
    <title><?=$page_title?></title>
</head>
<body>
    <?php foreach($result as $row):?>
    <h3><?=$row->title?></h3>
    <p><?=$row->text?></p>
    <br />
    <?php endforeach;?>
</body>


Test the $result if it is an array, before using foreach on it. Your result may be false since your database query failed, or returned no result.

if (is_array($result))
{
    foreach($result as $row)
    {
        /* ... */
    }
}


$result is not an array at all.

You should check the $result construction code. you are not setting $result properly.

If $result is supposed to hold database rows, checkout the database query if that is returning result properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜