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

Guys,


I wanted to know why you're giving the message of non-existent variable. Here are the model , controller and view my project. The problem is that it says that the variable $ banner is not set. Thank you


Error


Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: chupeta

Filename: views/index.php

Line Number: 129


Controller

Code:
class Banner extends CI_Controller {

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

    //Exibir informaçoes sobre o sistema
    public function index(){

          $this->load->model('Banner_model');
          $dados['banner'] = $this->Banner_model->get_banner();
          $this->load->view('index',$dados);


    }


}

Model

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

class Banner_model extends CI_Model {


    public function get_banner()
    {

        $query = $this->db->get('banner');
      return $query->result();
    }

}


Page

Code:
 foreach ($banner as $item){ ?>
             <li data-index="rs-1" data-transition="random" data-slotamount="7"  data-easein="default" data-easeout="default" data-masterspeed="1000"  data-thumb="images/banner3.jpg"  data-rotate="0"  data-fstransition="fade" data-fsmasterspeed="1500" data-fsslotamount="7" data-saveperformance="off"  data-title="Intro" data-description="">
               <!-- MAIN IMAGE -->
               <a href="<?php echo $item->link ?>" target="_blank"><img src='<?php echo base_url(); ?>assets/images/banner3.jpg'  alt=""  data-bgposition="center center" data-bgfit="cover" data-bgrepeat="no-repeat" class="rev-slidebg" data-bgparallax="5" data-no-retina></a>
             </li>

             <?php }?>
Reply
#2

You haven't shown line 129 of index.php, or else we would see $chupeta there, and it has not been declared or else you would not get this error. This is not a CodeIgniter issue, but rather a PHP issue. This is also just a PHP notice, which means that it would not stop execution. In a production environment (normally not displaying errors), you would not notice any problems. It is better to fix this and understand why. So, please show us line 129 of index.php, and also where and how you declared $chupeta. Everything you showed is useless for debugging.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB