Everything works fine when I have my application on my local server, but I can’t access the database on the production instance.
The index page loads with no problems (no DB access is required there).
As soon as I click to a page which needs DB access, I get an error message:
Fatal error: Call to a member function result_array() on a non-object in /home/… line 48.
Here is the code it fails on:
47: $query = $this->db->get($table_name);
48: return $query->result_array();
I deliberately changed the database.php file so that my DB credentials were incorrect, and had the same issue. I’m almost certain the credentials are correct though.
Is there somewhere else that affects the database connection?
Like the .htaccess?
Thank you all for your help with this!
I found the problem. It was indeed a database connectivity issue, but was a rookie mistake.
I thought that the $config[‘hostname’] should be the url of the website. But instead, it was just localhost. Hopefully nobody makes this silly mistake again.