• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function: _error_handler

#1
Hello i create a construct to make a menu like:


PHP Code:
public function __contruct() {
        parent::__contruct();
        $this->load->model('categorias_model''modelcategorias');
        $query $this->categorias $this->modelcategorias->listar_categorias();
        
    
}
    
    
    
public function index() {
        
        $dados
['categorias'] = $this->categorias;
        
        $this
->load->view('frontend/template/html-header'$dados);
.... 
but when i got this error:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: query
Filename: controllers/Home.php
Line Number: 17
Backtrace:
File: C:\xampp\htdocs\blog\application\controllers\Home.php
Line: 17
Function: _error_handler
File: C:\xampp\htdocs\blog\index.php
Line: 315
Function: require_once
Then i but here:

PHP Code:
public function index() {
 
       $this->load->model('categorias_model''modelcategorias');
 
       $query $this->categorias $this->modelcategorias->listar_categorias();
 
       $dados['categorias'] = $query

And works...It looks like it's not sending the construct to the index.
Reply

#2
The constructor is named "__construct" ... note the "s".

If you wish to set an instance variable inside it, use "$this->query", not "$query"
Reply

#3
I'm an dump writing wrong, sorry.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.