Yii Framework Forum: Chapter 9..php Notice Undefined Index: Comment In Page No 220 -224 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 9..php Notice Undefined Index: Comment In Page No 220 -224

#1 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 01 November 2012 - 05:38 AM

i am new in yii ,i am trying to adding user comments but here i am finding some difficulty such as....


PHP notice

Undefined index: Comment

C:\xampp\htdocs\trackstar\protected\controllers\IssueController.php(244)

232 * return the project model instance to whichthis issue belongs
233 */
234 public function getProject()
235 {
236 return $this->_project;
237 }
238
239 protected function createComment($issue)
240 {
241 $comment=new Comment;
242 if(isset($_POST['Comment']));
243 {
244 $comment->attributes=$_POST['Comment'];
245 if($issue->addComment($comment))
246 {
247 Yii::app()->user->setFlash('commentSubmitted',"Your comment has been added." );
248 $this->refresh();
249 }
250 }
251 return $comment;
252 }
253
254
255
256

Stack Trace
#0

C:\xampp\htdocs\trackstar\protected\controllers\IssueController.php(55): IssueController->createComment(Issue)

50 * @param integer $id the ID of the model to be displayed
51 */
52 public function actionView($id)
53 {
54 $issue=$this->loadModel($id, true);
55 $comment=$this->createComment($issue);
56 $this->render('view',array(
57 //'model'=>$issue,
58 'model'=>$this->loadModel($id, true),
59 'comment'=>$comment,
60 ));






my all codes are in files which is below....


I checked my code against the book code and didn't find any errors. If anyone have idea it wolud be appreciated.


thanks in advance...

Attached File(s)


0

#2 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 513
  • Joined: 08-August 09

Posted 02 November 2012 - 03:22 AM

Take a look at line 242 in IssueController. You have redundant semicolon there.

And please don't double post next time ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users