Search code examples
cakephpparse-error

cakephp: parse error in $this->model->field(


i'm getting the following syntax error: Parse error: parse error in C:\wamp\www\merry_flowers\controllers\merry_parents_controller.php on line 12. What am I doing wrong? thanks in advance.

when i try to run the following code:

<?php

var $merryparent_id=$this->MerryParent->field('id',
                                        array('MerryParent.name'=>$this.data['MerryParent']['name'],
                                        'MerryParent.email'=>$this->data['MerryParent']['email'])
                                        );
               ?>

Solution

  • You use:

    array('MerryParent.name'=>$this.data['MerryParent']['name']
    

    instead of:

    array('MerryParent.name'=>$this->data['MerryParent']['name']
    

    You're using a . instead of a -> to dereference $this.

    Change to "->", and it should work.