Php – parser error: syntax error, unexpected $data (T_VARIABLE) in codeIgniter

codeigniterPHPvariables

I am newbie in CodeIgniter. When I try to data passing with controller and view and model, I have got this:

Syntax error: Unexpected '$data'(T_VARIABLE) in c:\xampp\htdocs\ci\application\controllers\users.php on line 10

Here is my controller users.php code:

<?php
class Users extends CI_Controller
    {
        public function show()
            {
                $data['results']=$this->user_model->get_users();
                $this->load->view('user_view',$data);
             }
    }
?>

At views folder user_view.php code:

<body>
<?php
foreach($results as $object){
    echo $object->username;
}
?>
</body>

At model folder user_model.php code

<?php
class User_model extends CI_Model
    {
        public function get_users()
            {
                $query=$this->db->get('users');
                return $query->result();
            }
    }
?>

How can I solve this error?

Best Answer

Why do your error says c:\xampp\htdocs\ci\application\users.php shouldn't it have been c:\xampp\htdocs\ci\application\controller\users.php`

Related Topic