Welcome Guest, Not a member yet? Register   Sign In
Unexpected Variable help
#1

[eluser]Unknown[/eluser]
Model
Code:
<?php

class Dashboard_model extends CI_Model
{
    
    function __construct()
    {
        parent::__construct();
        $this->cmsLoad = $this->load->database('cms', TRUE);
        $this->postgresLoad = $this->load->database('postgres', TRUE);
        $this->load->helper('cookie');
    }
    
    function getPhoneStats()
    {
        $this->postgresLoad;
        if ($usercookie = $this->input->cookie('REMOTE_USER', TRUE))
        {
            #$sql = "SELECT * FROM cms.v_agent_state WHERE network_name='".$_COOKIE['REMOTE_USER']."'";
            $qstring = "SELECT * FROM cms.v_agent_state WHERE network_name = ?";
            $result = $this->db->query($qstring, array($usercookie));
            
            if ($result->num_rows() > 0)
            {
                return $result->result();
            }
        }
        else
        {
            return;
        }
    }
    
    function getAtxOtherInQ()
    {
        $this->cmsLoad;
        $this->db->select('skillname', 'numberqueuing', 'longest_queuing', 'staffed', 'available');
        $this->db->from('cms.v_latest_queues');
        $this->db->not_like('skillname', 'X');
        $this->db->or_not_like('skillname', 'Y');
        $atxSQL = $this->db->get();
                
        if ($atxSQL->num_rows() > 0)
        {
            $atxSQL->result();
        }
        else
        {
            return;
        }
    }
}
?>

And the Controller
Code:
<?php

class Dashboard_index extends CI_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->model('dashboard_model');
    }
    
    function index()
    {
        $data["phone_stats"]=$this->dashboard_model->getPhoneStats();
        $this->load->view('dashboard_view', $data);
    }
    
    function atxQueues()
    {
        $data["result"]=$this->dashboard_model->getAtxOtherInQ();
        $this->load->view('dashboard_view', $data);
    }
}
?>

In the view I just have come code that create a table for both functions.
The first function works fine, but the second function doesn't. When I load the page it will throw an error saying Undefined Variable: result
The next error will say invalid argument supplied for foreach, but that is probably because of the first error.
So to test if any variable worked, I did something similar to the Hello World tutorial. I made an array and then tried to display those on the view but it would still say that the variable was undefined.
#2

[eluser]Unknown[/eluser]
I figured out the problem. Instead of having two different functions I placed
Code:
$data["result"]=$this->dashboard_model->getAtxOtherInQ();
into the index() function and removed the second function.




Theme © iAndrew 2016 - Forum software by © MyBB