Possible Duplicate:
Call to a member function on a non-object
In my homepage view I’ve trying to pass data to my header sub-view
<?php
$this->load->model('header2');
$head = $this->header2->HeaderData();
$this->load->view('head_view', $head);
?>
but I get this error:
Message: Undefined property: CI_Loader::$header2
Fatal error: Call to a member function HeaderData() on a non-object in H:\Forum\application\views\homepage_view.php on line 6
write your code in controller method and load your view form there only, and use code like this
and in the head_view.php view access this property as $head like this
if you are loading main view and then calling subview in it then you don’t need to pass a value while loading view and you can directly access value in subview, so you can directly use
$headin subivew.