I am new to CakePHP.
Here i am pasting my standards_controller.php , new_student.ctp and
the model detail.php


<?php
class StandardsController extends AppController {

        var $name = 'Standards';
        //var $uses = array('Standard','Detail');
        var $components = array('Session');

        function add()
        {
                if(!empty($this->data)) {
                        if($this->Standard->save($this->data)) {
                                $this->Session->setFlash('Inserted new 
class!!');
                                $this->redirect(array('action' => 'index'));
                        }
                }
        }


        function new_student()
        {
                $class_details = $this->Standard->query("
 
SELECT id, class_name
                                                                              
FROM standards
                                                                        ");
                $this->set('class_details',$class_details);
                if(!empty($this->data)) {
                        if($this->Detail->save($this->data)) {
                                $this->Session->setFlash("Details saved 
successfully");
                                $this->redirect(array('action' => 'index'));
                        }
                        else {
                                $this->Session->setFlash("An error occured 
during insertion,Please
try again!!");
                                $this->redirect(array('action' => 'index'));
                        }
                }
        }
}
?>

Below is new_student.ctp
<?php
        echo $form->create(array('action' => 'new_student'));
        echo $form->text('name');
        for($i = 1; $i < 100; $i++)
        {
                $options[$i] = $i;
        }
        echo $form->select('Age',$options);
        foreach($class_details as $class_det)
        {
                $class_id[$class_det['standards']['id']] = 
$class_det['standards']
['class_name'];
        }
        echo $form->select('Class',$class_id);
        echo $form->submit('Save');
        echo $form->end();
?>

And here is detail.php
<?php
        class Detail extends AppModel {
                $name = "Detail";
                $validate = array(
                                                'name' => array('rule' => 
'notEmpty')
                                                'age' =>  array('rule' => 
'notEmpty')
                                                'class_id' => array('rule' => 
'notEmpty')
                                                );
        }
?>



The problem is that we i uncomment the var
$uses=array('Detail','Standard') it shows an error message,that i
pasted below.


Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION
in C:\xampp\htdocs\second_project\app\models\detail.php on line 3


Please help me to solve the problem.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to