Zack
Zack

Reputation: 2485

Blank page on auto-loading database library

Possible Duplicate: Problem with database in CodeIgniter

Alright, I've googled this the last two days to no avail. I'm received a few hits from SO and codeigniter's support forums and they're mostly misleading threads and "oops" mistakes by other people. I actually have two questions, but one I can hold onto for the sake of solving this mind boggler.

My Setup:

Alright so,

  1. I added the following line to my "welcome" controller, before the view gets loaded. CodeIgniter spits out the "Unable to load the requested class: database". I tried "Database" too, same thing.

    $this->load->library('database');

  2. I've tried $autoload['libraries'] = array('database'); which yields a blank page.

  3. I've also tried $autoload['libraries'] = array('Database'); which yields the preview page as seen in #1.
  4. I added error_reporting(E_ALL) above the inline load from the welcome controller and nothing else showed up.

I can only come to blame my inexperience with IIS that could be causing the issue.

EDIT: So, #1 has been fixed, auto-loading database, and, thanks to Ben, I had forgotten about "load->database(...)" method...

Anyway, my current error now is just a white page when the database is loaded via autoload. My code is just set to autoload the database and display the default view provided with CodeIgniter. Removing the database autoload causes the view to show...

Upvotes: 1

Views: 2583

Answers (2)

Eric Kigathi
Eric Kigathi

Reputation: 2021

Just a follow up to anyone having this same issue (including my future self).

Make sure that whichever dbdriver you are loading in your database config has the correct library (dll or so) loaded in php.ini

$db['default']['dbdriver'] = 'mysqli'; //MySQLi <-- mysqli.dll
$db['default']['dbdriver'] = 'mysql'; //MySQL <-- mysql.dll
$db['default']['dbdriver'] = 'pdo'; //PDO <-- pdo.dll

Failure to load the correct dll will cause CodeIgniter to fail with a blank page.

Upvotes: 1

Ben
Ben

Reputation: 2917

Your #2 option most likely worked fine, and some other unreported PHP error (check your CI logs) caused the blank page.

To manually load the database, use $this->load->database();

see this link for more

library() is for custom library files.

Upvotes: 3

Related Questions