Welcome Guest, Not a member yet? Register   Sign In
Unable to load requested class
#1

[eluser]brixxster[/eluser]
Hello again guys. I need your help again.

I get an error:

Unable to load the requested class: database

I don't know why this is happening since I already autoloaded the database library in the autoload.php under the config folder.

here's my code....

Code:
function updateapp (){
        $this->load->library('database');
        $data['internal_content'] = 'view_update_applicant';
        $data['headTitle']='Applicant Details Updated';
        
        // test the value of the submit button
        $action = $this->input->post('submit');
        if ($action == "Approve")
        {
            echo "aprroved";
        }
        else
        {
            $updatedata = array(
                'fname' => $this->input->post('fname'),
                'lname' => $this->input->post('lname'),
                'mname' => $this->input->post('mname'),
                'email' => $this->input->post('email'),
                'address' => $this->input->post('address'),
                'city' => $this->input->post('city'),
                'province' => $this->input->post('province'),
                'country' => $this->input->post('country'),
                'zip_code' => $this->input->post('zip_code'),
                'cellphone' => $this->input->post('cellphone'),
                'telephone' => $this->input->post('telephone'),
                'acct_id' => $this->input->post('acct_id')
            );
            
            $acct_id = $this->input->post('acct_id');
            
            $updateRec = $this->Model_dbmanagement->update_record($updatedata, $acct_id); // this one is causing the error so I loaded the database library again at the beginning of this function.
            
            $this->session->set_flashdata('action_message', 'Applicant information has been updated.');
            
            $this->appdetails($acct_id);
        }
    }

Hope you guys can help me again..
Thanks.
#2

[eluser]Peng Kong[/eluser]
if you already autoload the db library why do you still call it in your function?

Code:
function updateapp (){
        $this->load->library('database');
        ...

If you install a refresh CI and autoload DB and visit the Welcome controller you should get a messaging prompting you to setup the db connection.

once you setup the db connection everything should be as per normal.

i'm not sure why u get unable to load database.
#3

[eluser]brixxster[/eluser]
Hello peng kong..

I put it there because it seems like it's not loading the database library in the autoload.php. So just to make sure (may sound funny Big Grin) added it there.

I checked the database.php all is setup properly. I actually have other functions that communicates to the database and works fine but this one won't.

here is the code again without the database library loaded inside the function

Code:
function updateapp (){
        
        $data['internal_content'] = 'view_update_applicant';
        $data['headTitle']='Applicant Details Updated';
        
        // test the value of the submit button
        $action = $this->input->post('submit');
        if ($action == "Approve")
        {
            echo "aprroved";
        }
        else
        {
            $updatedata = array(
                'fname' => $this->input->post('fname'),
                'lname' => $this->input->post('lname'),
                'mname' => $this->input->post('mname'),
                'email' => $this->input->post('email'),
                'address' => $this->input->post('address'),
                'city' => $this->input->post('city'),
                'province' => $this->input->post('province'),
                'country' => $this->input->post('country'),
                'zip_code' => $this->input->post('zip_code'),
                'cellphone' => $this->input->post('cellphone'),
                'telephone' => $this->input->post('telephone'),
                'acct_id' => $this->input->post('acct_id')
            );
            
            $acct_id = $this->input->post('acct_id');
            
            $updateRec = $this->Model_dbmanagement->update_record($updatedata, $acct_id);
            
            $this->session->set_flashdata('action_message', 'Applicant information has been updated.');
            
            $this->appdetails($acct_id);
        }
    }

Is there something wrong with what I've written in the above code? I am basically new to CodeIgniter and Php and only taking and tweaking code snippets from samples I find on the internet.

Thanks again.
#4

[eluser]Peng Kong[/eluser]
ahhh... i see it now *i think* haha

Code:
$this->Model_dbmanagement->update_record($updatedata, $acct_id);

this line is the issue.

can paste another model function line from another function that works?


Code:
$this->Model_dbmanagement->DELETEORWHATEVER($bah, $bah);
#5

[eluser]Peng Kong[/eluser]
i got this strange feeling that 'Model_dbmanagement' has to be 'model_dbmanagement'
#6

[eluser]brixxster[/eluser]
Hey Peng Kong. You're an angel man! That capitalization did the error. But what I don't understand is I used this Model_dbmanagement with a capital "M" in other functions and it worked? Very strange... Anyways thanks for the help Peng Kong.

Hope you have a good day Wink
#7

[eluser]Peng Kong[/eluser]
haha np im glad it worked too!

from my limited knowledge windows based servers doesn't care if its 'M' or 'm' but UNIX based servers care.
never really bothered with why... as long as it works right Tongue
#8

[eluser]brixxster[/eluser]
Yep, right you are! Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB