Welcome Guest, Not a member yet? Register   Sign In
Undefined variable: content
#1

Hello,

I am trying to troubleshoot this:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: content
Filename: cms/index.php
Line Number: 101
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php
Line: 101
Function: _error_handler

------------------------------------


controllers\Site.php

PHP Code:
 // CONTENT //
 
       $data ['id_content']= $this->model_pages->id_content();
 
       $data ['content_name']= $this->model_pages->content_name();
 
       $data ['content']= $this->model_pages->content();
 
       $data ['content_images_1']= $this->model_pages->images(1);
 
       $data ['content_images_2']= $this->model_pages->images(2);
 
       $data ['content_images_3']= $this->model_pages->images(3);
 
       if$this->model_pages->id_content() ){
 
          $data ['h3'] = $this->model_pages->select_db('h3','cms_content','id="'.$this->model_pages->id_content().'"');
 
       }
 
       
        $data 
['q']= ''// For seacrh
 
       $data ['cms_pages_content']= $this->model_pages->cms_pages_content();
 
       $data ['post']= $this->model_pages->post();
 
       
        
        
// BANNER //
 
       $data ['slideshow']= $this->model_pages->cms_slideshow(1);
 
       $data ['footer']= $this->model_pages->footer();
 
       $data ['embed_code']= $this->model_pages->embed_code();
 
       $data ['memory_usage']=$this->benchmark->memory_usage();
 
       
       
       
        $msg 
rand(1000,9999);
 
       $key 'batman-VS-Superman';
 
       $encrypted_string $this->encrypt->encode($msg$key);
 
       $newdata = array(
 
           'token'  => $encrypted_string,
 
           'rand'   => $msg,
 
       );
 
       $this->session->set_userdata($newdata);
 
                     
        
      
        $this
->template $this->model_pages->template();
 
     
        if
($this->model_pages->template()){
 
           $template $this->model_pages->template();
 
       }else{
 
          $template "default";
 
       }
 
       $data['msg'] = $msg;
 
       $data['session' $this->encrypt->decode($this->session->userdata('token'), $key);
 
       $data['token'] = $this->session->userdata('token');
 
       
        $data
['template']=$this->template;
 
       
       
        $this
->load->view('header',$data);
 
       $this->load->view('cms/'.$template,$data);
 
       $this->load->view('footer',$data);
 
       
        
        $this
->db->close(); 


Model_pages.php

PHP Code:
function content($id_content=""){
 
       $content "";
 
       $result"";
 
       $option "";
 
       $module "";
 
       $replace "";
 
       $search "";
 
       $value "";
 
       
        $query 
"SELECT * from cms_content Where id = '".$this->id_content."'";
 
       $query $this->db->query($query);
$i 0


Any clue why the error appears?
" If I looks more intelligence please increase my reputation."
Reply
#2

Is "$this->id_content" assigned in model '__construct()' or initialized at the beginning of model class?
Second thing is to debug controller and at the beginning of the controller
(after model loading) put 'var_dump($this->model_pages->content());exit;'
Reply
#3

(This post was last modified: 04-09-2016, 11:26 AM by pb.sajjad.)

(04-09-2016, 01:15 AM)davy_yg Wrote: Hello,

I am trying to troubleshoot this:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: content
Filename: cms/index.php
Line Number: 101
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php
Line: 101
Function: _error_handler

------------------------------------


controllers\Site.php

PHP Code:
 // CONTENT //
 
       $data ['id_content']= $this->model_pages->id_content();
 
       $data ['content_name']= $this->model_pages->content_name();
 
       $data ['content']= $this->model_pages->content();
 
       $data ['content_images_1']= $this->model_pages->images(1);
 
       $data ['content_images_2']= $this->model_pages->images(2);
 
       $data ['content_images_3']= $this->model_pages->images(3);
 
       if$this->model_pages->id_content() ){
 
          $data ['h3'] = $this->model_pages->select_db('h3','cms_content','id="'.$this->model_pages->id_content().'"');
 
       }
 
       
        $data 
['q']= ''// For seacrh
 
       $data ['cms_pages_content']= $this->model_pages->cms_pages_content();
 
       $data ['post']= $this->model_pages->post();
 
       
        
        
// BANNER //
 
       $data ['slideshow']= $this->model_pages->cms_slideshow(1);
 
       $data ['footer']= $this->model_pages->footer();
 
       $data ['embed_code']= $this->model_pages->embed_code();
 
       $data ['memory_usage']=$this->benchmark->memory_usage();
 
       
       
       
        $msg 
rand(1000,9999);
 
       $key 'batman-VS-Superman';
 
       $encrypted_string $this->encrypt->encode($msg$key);
 
       $newdata = array(
 
           'token'  => $encrypted_string,
 
           'rand'   => $msg,
 
       );
 
       $this->session->set_userdata($newdata);
 
                     
        
      
        $this
->template $this->model_pages->template();
 
     
        if
($this->model_pages->template()){
 
           $template $this->model_pages->template();
 
       }else{
 
          $template "default";
 
       }
 
       $data['msg'] = $msg;
 
       $data['session' $this->encrypt->decode($this->session->userdata('token'), $key);
 
       $data['token'] = $this->session->userdata('token');
 
       
        $data
['template']=$this->template;
 
       
       
        $this
->load->view('header',$data);
 
       $this->load->view('cms/'.$template,$data);
 
       $this->load->view('footer',$data);
 
       
        
        $this
->db->close(); 


Model_pages.php

PHP Code:
function content($id_content=""){
 
       $content "";
 
       $result"";
 
       $option "";
 
       $module "";
 
       $replace "";
 
       $search "";
 
       $value "";
 
       
        $query 
"SELECT * from cms_content Where id = '".$this->id_content."'";
 
       $query $this->db->query($query);
$i 0


Any clue why the error appears?


You do not return anything in content function in Model!!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB