CodeIgniter Forums
Undefined variable: slideshow - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Undefined variable: slideshow (/thread-65406.html)

Pages: 1 2


Undefined variable: slideshow - davy_yg - 06-08-2016

I wonder why this error appears?


Code:
Undefined variable: slideshow


  line 107:  <?php foreach($slideshow as $row) : ?>


Code:
   A PHP Error was encountered

   Severity: Notice

   Message: Undefined variable: slideshow

   Filename: cms/index.php

   Line Number: 107

   Backtrace:

   File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php
   Line: 107
   Function: _error_handler

   File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\controllers\Welcome.php
   Line: 24
   Function: view

   File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\index.php
   Line: 315
   Function: require_once
   A PHP Error was encountered

   Severity: Warning

   Message: Invalid argument supplied for foreach()

   Filename: cms/index.php

   Line Number: 107

   Backtrace:

   File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php
   Line: 107
   Function: _error_handler

   File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\controllers\Welcome.php
   Line: 24
   Function: view

   File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\index.php
   Line: 315
   Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: content

Filename: cms/index.php

Line Number: 119

Backtrace:

File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php
Line: 119
Function: _error_handler

File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\controllers\Welcome.php
Line: 24
Function: view

File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\index.php
Line: 315
Function: require_once


controllers/Site.php

     
PHP Code:
// 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(); 


models/Model_pages.php


PHP Code:
 function cms_slideshow($id_slidshow_type ""){
 
 
       $query $this->db->query("select * from cms_slideshow where status = 1 and presence = 1 and id_slideshow_type = '".$id_slidshow_type."' order by sorting");

 
       return $query->result();
 
       //  return  'masuk loh';
 
 }
 
  



RE: Undefined variable: slideshow - Wouter60 - 06-09-2016

Because $query->result() returns an object, not an array. Use result_array() instead.


RE: Undefined variable: slideshow - davy_yg - 06-09-2016

models/Model_pages.php

PHP Code:
function cms_slideshow($id_slidshow_type ""){
 
 
       $query $this->db->query("select * from cms_slideshow where status = 1 and presence = 1 and id_slideshow_type = '".$id_slidshow_type."' order by sorting");

 
       return result_array();
 
       //  return  'masuk loh';
 
 



I try this.  I still have similar error:

  • A PHP Error was encounteredSeverity: NoticeMessage: Undefined variable: slideshowFilename: cms/index.phpLine Number: 107Backtrace:File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php Line: 107 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\controllers\Welcome.php Line: 24 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\index.php Line: 315 Function: require_once A PHP Error was encounteredSeverity: WarningMessage: Invalid argument supplied for foreach()Filename: cms/index.phpLine Number: 107Backtrace:File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php Line: 107 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\controllers\Welcome.php Line: 24 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\index.php Line: 315 Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: content
Filename: cms/index.php
Line Number: 119

Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php
Line: 119

Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\controllers\Welcome.php
Line: 24

Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\index.php
Line: 315

Function: require_once

[non-English redacted, tsk tsk!]


RE: Undefined variable: slideshow - arma7x - 06-10-2016

In controller;
PHP Code:
$data['slideshow']= $this->model_pages->cms_slideshow(1); 
slideshow
In View;
PHP Code:
NoticeMessageUndefined variable:slideshowFilenamecms/index.phpLine Number107Backtrace:FileC:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\innovationci3\application\views\cms\index.php 
slideshowFilename


RE: Undefined variable: slideshow - InsiteFX - 06-10-2016

If he checked the query return result he would know whats wrong!


RE: Undefined variable: slideshow - davy_yg - 06-10-2016

What changes should I make?


RE: Undefined variable: slideshow - suhindra - 06-10-2016

show us your complete view code,


RE: Undefined variable: slideshow - davy_yg - 06-10-2016

Here is the complete views codes:


views/slideshow_images.php

PHP Code:
<!DOCTYPE html>
<
html lang="en">
    <head>
        <title>Upgrade</title>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet/less" type="text/css" href="<?php echo base_url(); ?>assets/themes/less/bootstrap.less">
        <script src="<?php echo base_url(); ?>assets/themes/js/less/less.js" type="text/javascript"></script>
        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/fullcalendar.css" />    

        
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/delta.main.css" />
        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/delta.grey.css"/>
        
        
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/add.css"/>
        
    
</head>
    <body>
    <br>
    
    
<?php include('navigation.php'); ?>    
    
      <div id="mainBody">
            <h1>COMPANY PROFILE CMS
                <div class="pull-right">
                <a class="btn btn-large tip-bottom" title="Manage Users"><i class="icon-user"></i></a>
                <a class="btn btn-large tip-bottom" title="Manage Comments" style="position:relative"><i class="icon-comment"></i>
                <span style="position:absolute; border-radius:12px; top:-23%; height:16px; width:16px" class="label label-important">5</span></a>
                <a class="btn btn-large tip-bottom" title="Manage Orders"><i class="icon-shopping-cart"></i></a>
                <a class="btn btn-large btn-danger" title="" href="#"><i class="icon-off"></i></a>
                </div>
            </h1>
        <div id="breadcrumb">
            <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
            <a href="#" class="current">Dashboard</a>
        </div>
        
            <div class="row-fluid">
                <div class="span12">
                    
                    
                    Slideshow Name :  <input type="text"></input>
        
                    <button type="button" class="add" href="adminform.php">ADD SLIDESHOW</button> 
                    
                    
                    <div>
                    
                    <?php /* <a href='<?php echo site_url('images_examples/example1')?>'>Example 1 - Simple</a> |
                    <a href='<?php echo site_url('images_examples/example2')?>'>Example 2 - Ordering</a> |
                    <a href='<?php echo site_url('images_examples/example3/22')?>'>Example 3 - With group id</a> | */ 
?>
                    <a href='<?php echo site_url('cpages/slideshowimages')?>'>Example 4 - Images with title</a> | 
                    <?php /* <a href='<?php echo site_url('images_examples/simple_photo_gallery')?>'>Simple Photo Gallery</a> */ ?>
                    
                    </div>
                    
                    <div style='height:20px;'></div>  
                    <div>
                    <?php echo $output?>
                    </div>
                                        
                    <div class="widget-box">
                        <div class="widget-title"><h5>Slideshows</h5></div>
                        <div class="widget-content">
                        
                            
                        </div>
                    </div>                    
                </div>
            </div>
            
            
        </div>
        </div>

            <script src="<?php echo base_url(); ?>assets/themes/js/excanvas.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/jquery.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/jquery.ui.custom.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/bootstrap.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/jquery.flot.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/jquery.flot.resize.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/jquery.peity.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/fullcalendar.min.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/delta.js"></script>
            <script src="<?php echo base_url(); ?>assets/themes/js/delta.dashboard.js"></script>
    </body>
</html> 



RE: Undefined variable: slideshow - InsiteFX - 06-10-2016

NOTE:


Code:
<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
   <!-- Bootstrap 3.x.x -->

    ...

</head>



RE: Undefined variable: slideshow - davy_yg - 06-10-2016

http://127.0.0.1/CompanyProfileCI/index.php/cpages/slideshowimages


Still get this error message.


PHP Code:
[b]Fatal error[/b]: Call to undefined method Cpages::_example_output() in [b]C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\cpages.php[/bon line [b]116[/b]
A PHP Error was encountered
Severity
Error
Message
Call to undefined method Cpages::_example_output()
Filenamecontrollers/cpages.php
Line Number
116
Backtrace