0

Parse error: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\code\application\controllers\user.php on line 14

<?php

class User extends CI_Controller
{

    public function __construct()
    {
        parent:: __construct();
        $this->load->model('user_model');
    }

    public function get()
    {
        $this->user_model->(2);
    }
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
Ryan Abreu
  • 9
  • 1
  • 3

2 Answers2

1

Assuming user_model be a function, it should be

$this->user_model(2);

Or be the model, you are missing the function name. Should be -

$this->user_model->your_function(2);
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
0

This line

$this->user_model->(2);

should be

$this->user_model->your_method_name();

and inside () you can pass parameters as well

Example :

In controller

$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];

$this->user_model->your_method_name($name,$address, $phone);

In Model

function your_method_name($name,$address, $phone)
{
    //your query

}
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85