Welcome Guest, Not a member yet? Register   Sign In
having issues with Error: Trying to get Property of Non Object. Help!!!
#1

[eluser]reghan[/eluser]
Hello I am getting the error trying to get property of non object.
here is my code

Model:
Code:
<?php
class Department_model extends CI_Model {

public function __construct()
{
  $this->load->database();
}

function depart_table_list() //list the departments names
{
  $this->db->order_by('DepartmentName', 'asc');
  return $this->db->get('department');
}


// get department by id
function get_by_id($id){

  $this->db->where('DepartmentId', $id);
  return $this->db->get('Department');
}

}
Controller function:
Code:
function get_dept_info()
{

  $id = $this->uri->segment(3);
  $dept_info = $this->department_model->get_by_id($id);
  $data['department'] = $dept_info->result();


                $this->load->view('dept_info', $data);

}
view:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
<h3 align="center">Business Impact Analysis(BIA) Questionnaire</h3>
<h5 align="center">&lt;?php echo $department->DepartmentName; ?&gt;</h5>








&lt;/body&gt;
&lt;/html&gt;

I basically am just looking to print out the department name based on the id selected. I feel like this should be simple and am not really sure where I am going wrong.

Thanks to all who reply!!


Messages In This Thread
having issues with Error: Trying to get Property of Non Object. Help!!! - by El Forum - 05-30-2012, 07:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB