[eluser]dan.syme[/eluser]
I am having trouble declaring a variable that can be used throughout the functions in my controller.
snippet below I get Message: Undefined variable: errors for a my variables.
I wanted to clean up my code so I didn't have to declare all my variables for each function with in the controller.
Code:
<?php
class sim_audio_presets extends Controller {
function sim_audio_presets()
{
parent::Controller();
//load libraries and helpers
$this->load->library('user_agent');
$this->load->helper('socket');
$this->load->helper('url');
//Set Database Table
$table = 'sim_audio_presets';
//Set callback server
$server = '************';
$port = '****';
}
function get()
{
$id = $this->uri->segment(3);
$this->db->where('room_id', $id);
$query = $this->db->get($table);
foreach ($query->result() as $row)
{
$data[] = array('id' => $row->id,
'room_id' => $row->room_id,
'preset' => $row->preset,
'name' => $row->name);
}
$json = '{"'. $table .'":' . json_encode($data) . '}';
$data['json'] = $json;
$this->load->view('responder', $data);
}