I'm trying to work with the codeigniter CMS BONFIRE.I've used codeigniter before, I actually have an installation of both pure codeigniter and bonfire on my local server.First off I've been having trouble with my .htacess files on my xammp server but that's a topic for another day.My Bonfire installation for some reason will not recognize my database settings in application/config/database.php
they are something like

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '$username';
$db['default']['password'] = '$password';
$db['default']['database'] = 'bonfire';
$db['default']['port']     = '3306';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = 'bf_';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = TRUE;

where $ username is my username and $ password is my password but (obviously i cant show it).
i get this error

A Database Error Occurred
Unable to connect to your database server using the provided settings.

Filename: C:\xampp\htdocs\Bonfire-master\bonfire\codeigniter\database\DB_driver.php

Line Number: 124

Dani AI

Generated

Brief recap and context: has a Bonfire (CodeIgniter) site on XAMPP that returns the generic "Unable to connect" DB error. already suggested exposing the underlying MySQL error and reminded about copying database.php into the environment folder; pointed out the OP likely scrubbed real credentials from the posted snippet. The problem space is small: either the MySQL server/credentials are wrong, the PHP MySQL extension or CI driver is wrong, or Bonfire is loading a different config file than the one being edited.

Practical, prioritized checklist (work top→bottom)

  • Confirm MySQL is actually running in the XAMPP control panel and that the database named in the config exists.
  • Verify the credentials outside Bonfire (phpMyAdmin or a quick CLI connect using host, user, password and port) so the server/privileges are proven independently of CI.
  • Check which config file CodeIgniter is loading: inspect the ENVIRONMENT constant in index.php and make sure the same database.php is present in the corresponding application/config/<environment>/ folder (as noted).
  • Verify PHP has the appropriate extension enabled (mysqli or pdo_mysql) — if PHP is recent, the old mysql extension will be missing and the mysql driver will fail; prefer mysqli or pdo in the DB config.
  • Try the hostname as 127.0.0.1 (or 127.0.0.1:3306) instead of localhost — some CI drivers ignore the separate port key and require host:port in the hostname string.
  • Turn on PHP error display and check Apache/PHP and CodeIgniter logs (application/logs); do not rely solely on the generic CI message. Avoid leaving any core driver hacks in place after debugging.

Notes and cautions: avoid leaving debug code (like modifications to core drivers) active; revert those changes after capturing the real error. If PyroCMS connects successfully from the same XAMPP instance, that strongly points to a CI/Bonfire config, driver, or environment mismatch rather than a MySQL server problem.

Recommended Answers

All 5 Replies

Seems fine, go to

C:\xampp\htdocs\Bonfire-master\bonfire\codeigniter\database\drivers\mysql\mysql_driver.php

Line 73, method db_connect(), you find:

return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);

change it, temporarly for this issue, to:

return mysql_connect($this->hostname, $this->username, $this->password, TRUE) or die(mysql_error());

And then reload the page, you should see the real error that makes the connection fail.

//EDIT

By the way, in order to complete the setup process in Bonfire, you have to copy the database.php file into the development directory, so copy:

bonfire/application/config/database.php

To:

bonfire/application/config/development/

Just copy, do not move it. Bye!

Thank you , no errors are displayed , thank you for suggesting about moving the database.php file to different evironments.However I'm still getting the error.I'm getting frustrated ,I Love codeigniter and bonfire is just like it, I'm about to give up and use pyrocms which is connecting with no errors but I'd prefer not to use a templating engine.

You're welcome!

I would try to change the database configuration values, line per line, and verifying if there are some changes. In particular I would focus on these lines:

$active_record = TRUE;

$db['default']['username'] = '$username';
$db['default']['password'] = '$password';

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

$db['default']['dbdriver'] = 'mysql';

In order: try to set active record to FALSE, be sure that username and password are correctly set, right now with single quotes PHP will send literally $username & $password, not the assigned values, to send those you have to use double quotes:

$db['default']['username'] = "$username";
$db['default']['password'] = "$password";

Or simply remove them:

$db['default']['username'] = $username;
$db['default']['password'] = $password;

Not sure the issue is this, but it could be, at first I thought your was a simple edit to cover your credentials...

Be sure the database is listening port 3306 and that is not served through a local socket.

Regarding the driver, instead, you could try by setting mysqli or pdo and see what it happens.

: OP said those are just replaced in this code... I gather... or verbatim, "where $ username is my username and $ password is my password but (obviously i cant show it)" so I'm guessing that's not how it actually is in his code

I believe it also, for this reason I wrote:

at first I thought your was a simple edit to cover your credentials...

since English is not my main language, and being in doubt, I prefer to make an obvious observation. Thanks for the clarification :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.