PHP notice

Trying to get property of non-object

/var/www/shopthucphamchucnang.com/themes/thucphamchucnang/views/news/detail.php(3)

01 <?php
02     $news = News::model()->findByPk($id);
03     $this->title = $news->category->name;
04     
05     if(!isset($news)){
06         throw new CHttpException(404,'Địa chỉ không hợp lệ');
07     }
08     else{
09         $news->visited();
10     }
11                 
12     $this->meta_title=$news->meta_title;
13     $this->meta_keyword=$news->meta_keyword;
14     $this->meta_description=$news->meta_description;
15     $this->canonical=$news->detail_url;

Stack Trace

#4
+
 /var/www/shopthucphamchucnang.com/protected/modules/frontend/controllers/SiteController.php(131): CController->render("/news/detail", array("id" => "1150"))
126                     ));
127                 }
128                 break;
129             case 'n':
130                 $this->render('/news/detail',array(
131                     'id'=>$id,
132                 ));
133                 break;
134             case 'cqa':
135                 if(isset($_GET['is_ajax']) && $_GET['is_ajax']==1){
136                     $data = $this->renderPartial('/qA/_list',array(
#19
+
 /var/www/shopthucphamchucnang.com/index.php(77): CApplication->run()
72         Yii::app()->params['is_admin'] = true;
73     }
74 }
75 date_default_timezone_set('Asia/Ho_Chi_Minh');
76 
77 $app->run ();
2024-03-29 14:16:41 nginx/1.10.3 Yii Framework/1.1.14