PHP warning

Invalid argument supplied for foreach()

/home/havailam/public_html/protected/views/site/fullpost.php(173)

161 
162             <br/>
163           <div class="col-xs-12 col-sm-12">
164            <p class="pd-10 info">     
165                <i class="glyphicon glyphicon-user c1" ></i>
166                &nbsp;<?php echo $post->user->user_name; ?>&nbsp;
167                <i class="glyphicon glyphicon-calendar g1" ></i>
168                &nbsp;<?php if(Yii::app()->language=="fa"){ echo Yii::app()->jdate->date("l Y/m/d", $post->time); } if(Yii::app()->language=="en"){echo date('d F Y',time());} ?><i class="glyphicon glyphicon-list-alt"></i>
169                &nbsp;<b><?php echo $post->view; ?></b>:<?php echo yii::t('app','Views'); ?>
170                          <?php
171                         $comments=array();
172                         $approvedComment=0;
173                         foreach ($post->comments as $commentModel) {
174                             if ($commentModel->approved == CommentsHelper::APPROVED) {
175 //                                array_unshift($comments, array('id' => $commentModel->id, 'content' => $commentModel->content,
176 //                                    'user' => $commentModel->user, 'time' => $commentModel->time,'parent'=>$comment->parent0));
177                                 array_unshift($comments,$commentModel);
178                                 $approvedComment++;
179                             }
180                         }
181                         ?>
182                     
183                      <i class="glyphicon glyphicon-comment "></i>&nbsp;<?php echo yii::t('app','Total Comments'); ?>
184                       <b><span class="badge badge-danger"><?php echo($approvedComment) ?></span></b>
185                       

Stack Trace

#4
+
 /home/havailam/public_html/protected/controllers/SiteController.php(184): CController->render("fullpost", array("post" => array(), "polling" => Polling, "online_counter" => "23", "today_counter" => "2114", ...))
179                 $model->save();
180                 $this->setPageTitle($model->title);
181                 $this->render('fullpost', array_merge(array('post' => $model, 'polling' => $polling), $statistics));
182 
183             } else {
184                 $this->render('fullpost', array_merge(array('post' => array(), 'polling' => $polling), $statistics));
185             }
186         }
187     }
188 
189     public function actionprint()
#12
+
 /home/havailam/public_html/index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
2024-03-19 10:55:30 LiteSpeed Yii Framework/1.1.15