Welcome Guest, Not a member yet? Register   Sign In
Variable not being passed
#1

[eluser]Booster77[/eluser]
Hello everyone,

I'm staring myself blind at my code at the moment. I have succesfully implemented this method before but somehow it won't work now. I'm trying to get a versionnumber out of my database and display it in the footer. But whatever I try it will not pass the variable to the view. I've literally copied the code from a working version I have on another page. I'm hoping I'm looking over something really simple. To make it easier to spot I've replaced the function for a static value, but that also doesn't work. Can you please look at my code and see what I'm doing wrong? Thank you so much in advance

My model (which in this example is not being used but is being called so I've included it for you):
Code:
<?PHP
class Versionxmodel extends CI_Model
{
   function __construct()
   {
      parent::__construct();
   }
  
    function getcurrentversion()
    {
  $kw = "SELECT parvalue FROM sys_par WHERE parname = 'versionnumber'";
        $query = $this->db->query($kw);
        return $query->result();
    }
  
}
?>

My controller:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Footer extends CI_Controller
{
function __construct()
{
  parent::__construct();

  $this->load->helper('url');
  $this->load->model('versionxmodel');
}

function index()
{
  
  //$versionresult = $this->versionxmodel->getcurrentversion();
  $testvalue = 'testvalue';
  $data = array('test' => $testvalue);
  $this->load->view('footer', $data);
  
  
}
}
?>

My view:
Code:
<FOOTER>
&lt;?PHP

print_r($test);

if ($this->ion_auth->logged_in())
  {
   $user = $this->ion_auth->user()->row();
  }

?&gt;
Logged in as:
&lt;?PHP
if ($this->ion_auth->logged_in()){
echo $user->username;  
}
else
{
echo "Nobody!";

}
if ($this->ion_auth->is_admin())
  {
   echo " (+) ";
   }
  
?&gt;

</FOOTER>

The error I keep getting (wether I try print_r($test); or echo $test; ) is Undefined variable: test


Messages In This Thread
Variable not being passed - by El Forum - 12-26-2013, 04:20 AM
Variable not being passed - by El Forum - 12-26-2013, 04:43 AM
Variable not being passed - by El Forum - 12-26-2013, 04:45 AM
Variable not being passed - by El Forum - 12-26-2013, 04:49 AM
Variable not being passed - by El Forum - 12-26-2013, 04:57 AM
Variable not being passed - by El Forum - 12-26-2013, 05:12 AM
Variable not being passed - by El Forum - 12-26-2013, 05:16 AM
Variable not being passed - by El Forum - 12-26-2013, 02:50 PM
Variable not being passed - by El Forum - 12-27-2013, 04:13 AM
Variable not being passed - by El Forum - 12-27-2013, 04:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB