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

[eluser]GamingFusion[/eluser]
I have a page that needs to get data from the database and place it into fields but my function in the model i think isnt working right but i not sure what isn't working

Controller
Code:
function general()
    {
        $this->adminCheck();
        
        $this->database->getFieldsAll('info');
        
        if ($query)
        {
            $query = "SELECT * FROM info ";
            $result = $this->db->query($query);
            $check = $result->num_rows();
            
            if ($check > 0)
            {
                $data['siteName'] =  $this->input->post('sitename');
                $data['siteUrl'] =  $this->input->post('siteurl');
                $data['adminEmail'] =  $this->input->post('admine');
                $data['welcome'] =  $this->input->post('welcome');
            }
        }
        
        //Set Data
        $data['title'] = 'Theater 311 | General Settings';
        $data['heading'] = 'General Settings';
        $data['css'] = 'site';
        $data['content'] = 'admin/general';
        
        //Load View
        $this->load->view('admin/template/index', $data);
    }

model
Code:
function getFieldsAll($table)
    {
        $query = $this->db->get($table);
        
        if ($query->num_rows == 1)
        {
            return true;
        }
    }
#2

[eluser]bigtony[/eluser]
You're going to kick yourself...
Code:
// change this
$this->database->getFieldsAll('info');

// to this
$query = $this->database->getFieldsAll('info');
Also, in your getFieldsAll() function, if the number of rows is not 1 you are not returning anything, but surely you should return FALSE in these instance, like this:
Code:
// this will correctly return TRUE or FALSE
return ($query->num_rows == 1);
#3

[eluser]GamingFusion[/eluser]
thanks man i did kick myself for that. and thanks for the tip




Theme © iAndrew 2016 - Forum software by © MyBB