codeigniter array variable

By : JonYork
Source: Stackoverflow.com
Question!

Here is my code so far, it all works except when I try to make 'company' = $company there's something im missing, and id love to know what

if($query) // if the user's credentials validated///
    {
        $this->db->where('username');
        $this->db->select('company');
        $company = $this->db->get('user');

        $data = array(
            'username' => $this->input->post('username'),
            'company' => $company
            'is_logged_in' => true
        );
        $this->session->set_userdata($data);
        redirect('site/members_area');
    }
    else
    {
        $this->index();
    }
By : JonYork


Answers

There is a missing comma after "$company".

EDIT: Based on the discussion in the comments, I've rewritten your code to (hopefully) get the value of the company:

if($query) {
  $username = $this-


result_array is a function, not a variable. Try

if($query) {
  $username = $this-
By : Adi


Both the other answers fix one of the two errors in your code, this is an addition.

if($query) {
  $username = $this-


This video can help you solving your question :)
By: admin