• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tracking down a DB connection error

I've set-up my database connecting info in config file (database.php)

I change the autoload.php file to load the database connect automatically.

But now none of my pages will render, and I can't find an error message anywhere - not displayed on the screen (say, when I run the welcome page) and not in the apache error.log.

I'm running xampp on my local PC - MySql and Aapache.

Help on where to look for the error message would be appreciated!


Hello philmctim, welcome to the CI forums!

There are a couple things I would do, first, look at the source code of that "white page" you may find that there are actualy errors before the page is rendered. I once found error messages in my javacode from CI. It stopped execution and I was left with a white page that was halfway rendered, looking at the source then showed me the error. Second, I would verify that it is the fact that loading the database library is the cause. Remove it from autoload and see if it all works again. If so, then we know it is related to the database library. More then likely something that is keeping you from connecting to the database.

There is a CI log ability but I have never played with it. It is well documented in the user guide however.

Thanks for the welcome!

It's definitely the autoload change - I can toggle the autoload of the database and get a blank page or a correct page.

The HTML is blank - the server is reporting a "500" internal server error.


What PHP, MySQL (Database) versions are you using? It may be something with your server config. I myself had to go from MySQL 4 to 5 in order to get it to work.

It's 5.0.51b

$active_group = "default";
$active_record = TRUE;

Does this look okay for my db config? I find it surprising that the port number isn't required, but the doc says it's only for Postgres.

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "cf_dev";
$db['default']['password'] = "mypassword";
$db['default']['database'] = "cf_dev_db";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci"

I moved the


into a try/catch block in my controller...still crashes, no exception.

I'm sure there'll be a log file populated somewhere...just can't find it..

Okay, I think I cracked it...

The problem was with my PHP config. There was an old php.ini in /programfiles/php which wasn't loading mysql.

I removed it and things started working.

Haven't had a chance to actually use the db yet, but at least it looks like I can connect.

Thanks for your help!

Glad to hear you found the problem!
Not a problem, always willing to help.


I too am having this same problem with adding 'database' to the autoload.php file specifically on my local development setup. Everything works just fine on my remote host.

I'm starting with a very clean, new installation of CI version 1.7.0 and doing everything EXACTLY as stated in the User Guide. I've even started over a couple of times by deleting my CI installation and re-copying a new installation into my htdocs root. Still, same problems.

I've been going through the forum and trying various suggested solutions but to no avail still.

Here is a profile of my development environment:
- Windows XP Pro
- Apache 2.2.11
- mod_rewrite IS ENABLED (I always have this enabled)
- All statements of AllowOverride are set to All
- PHP 5
- MySQL 5.1
- CodeIgniter 1.7.0, index.php and the /system folder of core files are copied to a test site area on my computer at: C:\Apache\htdocs\blogtest

My pages otherwise render just fine when I leave the setting as:

$autoload['libraries'] = array('');

However, when I add the database library in as stated in as:

$autoload['libraries'] = array('database');

...I then get a blank page.

When I view the source to see if there are any error messages, I see nothing. There is no source code either. Blank view page AND blank source code.

I even wrote a separate non-CI test page to test connection to the database to make extra sure and was able to do so without errors so I know I'm using the correct database connection credentials.

Another thing I've noticed and have read that other users have noticed (but still cannot actually find an answer) is that there doesn't seem to even be a Database.php class file in the /system/libraries directory. My assumption may be wrong (please correct me if it is) but I thought that was where $autoload['libraries'] was looking for any libraries being called.

If I forgot to list additional info on how my environment is set up, please let me know.

Any assistance is greatly appreciated!!!! I'm pulling my hair out on this one.

Thank you!!
- Tony

Database is an exception, it's located in system/database.

Go into application/config/database.php and add;

$db['default']['port'] = 3306;

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.