MelusDecus
MelusDecus

Reputation: 81

codeigniter class error

For some reason i cant get my model to work.. never had this problem before.

function overview($userid)
{

    // Load needed model
    $this->load->model('budget_model');
    $data['month_budget'] = $this->budget_model->get_monthly_budget($userid);

    if(isset($_POST['submit']))
    {

        foreach($_POST as $key => $value)
        {

            if(is_numeric($key))
            {
                $this->buget_model->update_buget($key,$value);
                echo "DONE";
            }

        }       

        echo "<pre>";
        print_r($_POST);
        echo "</pre>";
    }

    $data['main'] = 'super_admin/budget_edit_overview_view';
    $this->load->view('default/main_view',$data);

}

The model works fine with "$this->budget_model->get_monthly_budget($userid);" but i keep getting thir error,

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Admin::$buget_model

Filename: controllers/admin.php

Line Number: 166

Fatal error: Call to a member function update_buget() on a non-object in /Applications/MAMP/htdocs/therace/application/controllers/admin.php on line 166

The model method,

function update_buget($id,$budget)
{

    $this->db->where('id', $id);

    // Update the month budget
    $data = array(
        'month_goal' => $budget
    );

    $this->db->update('budget_month', $data);

    return true;

}

Upvotes: 0

Views: 75

Answers (2)

Sree
Sree

Reputation: 539

You have made a typing error in line 166.

It is $this->budget_model->update_buget($key,$value);

not $this->buget_model->update_buget($key,$value);

Upvotes: 0

sevenseacat
sevenseacat

Reputation: 25029

Read the error message carefully:

Message: Undefined property: Admin::$buget_model

Did you make a typo and actually mean $budget_model?

edit: There seems to be a lot of budget vs. buget in your code. I suggest a spellchecker.

Upvotes: 2

Related Questions