CodeIgniter Forums
$this->data, server error? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->data, server error? (/showthread.php?tid=48614)



$this->data, server error? - El Forum - 01-23-2012

[eluser]solid9[/eluser]
Don't know the reason,

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');



class Main extends CI_Controller {

public $data['header'] = $this->load->view('header', null, TRUE);

public function __construct() {
  parent::__construct();

  $this->load->helper('form');
  $this->load->helper('html');
  $this->load->helper('url');    
  $this->load->library('ion_auth');
  $this->load->library('session');
  $this->load->library('form_validation');
  $this->load->database();

  //$this->load->model('prod_m');
}

public function index()
{
  if (!$this->ion_auth->logged_in())
  {
   //redirect them to the login page
   redirect('main/login', 'refresh');
  }
        }

//log the user in
function login()
{
  $this->load->view('front_page', $this->data);
}
}


Can you spot the not of $this->data ?

Thanks.


$this->data, server error? - El Forum - 01-23-2012

[eluser]keevitaja[/eluser]
Code:
public $data['header'] = $this->load->view('header', null, TRUE);

you can't call $this outside method...


$this->data, server error? - El Forum - 01-23-2012

[eluser]Jason Stanley[/eluser]
You should post the actual error.

Anyway, the problem is caused here.

Code:
public $data['header'] = $this->load->view('header', null, TRUE);

Change To:

Code:
public $data['header'] = '';

public function __construct() {
  parent::__construct();
  $this->data['header'] = $this->load->view('header', null, TRUE);



$this->data, server error? - El Forum - 01-23-2012

[eluser]solid9[/eluser]
thanks guys but I already solved the problem.