Take the 2-minute tour ×

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:

  • FRESH CodeIgniter 2.1
  • IIS 7.5, FastCGI+PHP 5.4.4
  • Windows 7 Professional x64

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.


  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...

share|improve this question
What is the database class? Is it a custom one you downloaded because there is none in official user guide. –  Shubham Jun 27 '12 at 4:28
@Shubham its all there in system\database folder –  Kinjal Dixit Jun 27 '12 at 4:40
@kinjal: What I meant was it can't be loaded using load->library?.. or is it? –  Shubham Jun 27 '12 at 5:18
Ok I get it now. I guess I was wrong.! –  Shubham Jun 27 '12 at 5:35
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
check your database configuration application\config\database.php. Most likely you dont have php_mysql modules installed/enabled. –  Kinjal Dixit Jun 27 '12 at 4:35
Edited my question, appears the database loading was working (not to mention I was loading it wrong within the controller, but we won't touch that :P). However, the white page still persists. –  Zack Jun 27 '12 at 4:42
@kinjal that was the issue. PHP wasn't configured properly + mysql module(s) weren't loaded. Thanks! –  Zack Jun 27 '12 at 6:16
add comment

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.

share|improve this answer
add comment

Your Answer


