0

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;

}
1
  • Class name should start with Uppercase? Commented Dec 4, 2012 at 8:20

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Agreed, I see $this->budget_model-> and $this->buget_model-> in the controller function
I suggest proper IDE. spelling error doesn't matter much in programming as long as those spelling error are CONSISTANT.
0

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.