PHP warning

Invalid argument supplied for foreach()

/mnt/wwwroot/388g/shebao.388g.com/protected/modules/mshebao/views/shebao/show_content_2.php(154)

142 <div class="mainbody" <?php echo ($flag!=1)?'style="border-bottom:none"':''?>>
143     <div class="hd"><strong>相关文章</strong></div>
144     <div class="bd">
145         <ul class="plist clearfix">
146             <?php
147             if($flag==1){
148             $xgwzmodel = Post::model()->findAllBySql("select * from bage_post where status_is='N' and catalog_id=".$_v['id']);
149             }else if($flag==2){
150             $xgwzmodel = Post::model()->findAllBySql("select * from bage_post where status_is='N' and title like '%".$_v['catalog_name']."%' order by create_time limit 0,8");
151             }
152 
153             $i=0;
154             foreach ($xgwzmodel as $xg){
155                 $pat = '/\/uploads(.*?)"/is';
156                 preg_match_all($pat, $xg['content'], $mm);
157                             echo ($i==0)?'<li class="first">':'<li>';
158                             echo '<a href="'.Post::model()->getmUrl($xg['id']).'"><img src="'. $mm[0][0].'" alt=""/><p>'.$xg['title'].'</p>
159                 </a>';
160                             echo '</li>';
161             ++$i;
162             if($i==4) break;
163             }?>
164         </ul>
165         <ul class="tlist clearfix" style="margin-top: 5px">
166             <?php

Stack Trace

#4
+
 /mnt/wwwroot/388g/shebao.388g.com/protected/modules/mshebao/controllers/ShebaoController.php(93): CController->render("show_content_2", array("_v" => Catalog, "lanmu" => "sbj", "sheng" => "zhejiang", "shi" => "lishui"))
88             $this->render('show_content_2', [
89                 '_v' => $catalogArr,
90                 'lanmu' => $lanmu,
91                 'sheng' => $sheng,
92                 'shi' => $shi,
93             ]);
94         }
95         else if ($sheng)
96         {
97             $this->render('show_content_2', [
98                 '_v' => $catalogArr,
#12
+
 /mnt/wwwroot/388g/shebao.388g.com/index.php(20): CApplication->run()
15 define('WWWPATH', str_replace(array('\\', '\\\\'), '/', dirname(__FILE__)));
16 $framework = dirname(__FILE__) . DS. 'framework'.DS.'yiilite.php';
17 $config = WWWPATH . DS .'protected'.DS.'config'.DS.'main.php';
18 defined('YII_DEBUG') or define('YII_DEBUG',true);
19 require_once ($framework);
20 Yii::createWebApplication($config)->run();
2024-03-28 23:25:42 nginx/1.24.0 Yii Framework/1.1.14