0

while making a friendship system in cakephp, i got error something like this in my friend controller---->

syntax error, unexpected ';'

pls someone sort out this problem.... here is my friendship controller code:

<?php
App::uses('AppController', 'Controller');
/**
 * Posts Controller
 *
 * @property Post $Post
 * @property PaginatorComponent $Paginator
 */
class FriendsController extends AppController 
{

/**
 * Components
 *
 * @var array
 */
    var $layout=null;
    public $components = array('Paginator');
    function index()
    {


    }

 function friendlist($user_id)
         {
                    $session_user_id = $this->Session->read('Auth.User.id');
                    if($user_id == $session_user_id )
                    {
                        $user_to = $session_user_id ;
                    }
                    else
                    {
                        $user_to = $user_id;
                    }
                    $this->Friend->find('all',array('Friend.user_to'=>$user_to,'Friend.status'=>'Accepted');
         }

function add_friend ( $id )
{
    if(!empty($this->data))
    {
        $this->Friend->Create();
        if($this->Friend->save($this->data))
        {
            $this->Session->setFlash('Friendship Requested');
            $this->redirect(array('controller'=>'users','action'=>'login'));
        }
    }
if(empty($this->data))
    {
        $this->set('friends', $this->Friend->find('all',array('Friend.id'=>$id));
    }
}


    function accept_friendship ( $id )
             {
            $this->Friend->id = $id;
            $current_status = $this->Friend->field('status');

            if($current_status=='Requested') {
                $this->Application->saveField('status', 'Accepted');
            }

            $this->Session->setFlash('Friendship Accepted');
            $this->redirect(array('controller'=>'friends','action'=>'index'));
        }



}
ndm
  • 59,784
  • 9
  • 71
  • 110
abhishek
  • 120
  • 10

2 Answers2

0

Syntax error. In line 36 and in line 52. You forget to add closing bracket

Change code from

$this->Friend->find('all',array('Friend.user_to'=>$user_to,'Friend.status'=>'Accepted');

to

$this->Friend->find('all',array('Friend.user_to'=>$user_to,'Friend.status'=>'Accepted'));

from

$this->set('friends', $this->Friend->find('all',array('Friend.id'=>$id));

to

$this->set('friends', $this->Friend->find('all',array('Friend.id'=>$id)));
VijayNaidu
  • 716
  • 5
  • 5
0

Simply there is the problem with syntax,where you forget to close brackets in find and set syntax

Add following code and try :

$this->Friend->find('all',array('Friend.user_to'=>$user_to,'Friend.status'=>'Accepted'));

and

$this->set('friends', $this->Friend->find('all',array('Friend.id'=>$id)));

And my suggestion to you that please use some nice one editor which helps you with syntax errors, like I am using netbeans and its best.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Er.KT
  • 2,852
  • 1
  • 36
  • 70