Welcome Guest, Not a member yet? Register   Sign In
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




Theme © iAndrew 2016 - Forum software by © MyBB