I am getting this very strange error "Cannot use a scalar value as an array" neither google god nor stuffs on SOF helped me this what i am trying to do is i have already created user session[with session data username and password] now after user login on my_profile page i am appending some session data like user_id then i start getting this error??? Any help or Hints
//controller
<?php
class My_profile extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
$this->load->helper('html');
$this->load->database();
$this->load->library('form_validation');
// $this->is_login();
}
public function index () {
if($this->session->userdata('is_login')) {
$session_data = $this->session->userdata('is_login');
$session_data['user_id'] = $this->session->userdata('user_id');
$this->session->set_userdata("is_login", $session_data);
$this->load->model('My_profilee');
$data['query']=$this->My_profilee->view_data();
$this->load->helper('url');
$this->load->view('header2');
$this->load->view('my_profile');
// $this->load->view('footer');
}else {
echo "you don't have permission to access this page <a href=../Homecontroller/index/>Login</a>";
die();
}
}
}
?>
//model
<?php
class My_profilee extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->database();
}
public function view_data() {
//echo $this->session->userdata('user_id');
$query=$this->db->get('tbl_usrs');
return $query->result();
}
}
?>
what i am really trying to do is to add user id [from databse] of user after login into session data and then display user information according to user id??