Welcome Guest, Not a member yet? Register   Sign In
database error using virtual hosts

Hi guys,

I'm changing my projects for to use virtual hosts on windows seven, but when I changed my first codeigniter project to use virtual hosts, acessing the project I came across the following problem:

A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: D:\xampp\htdocs\project\system\database\DB_driver.php
Line Number: 124

But if I access like old way: http://localhost/project, no has the error, the site opened ok.

The other projects that don't using codeigniter are ok too. This is happening with only codeigniter projects.

Anybody already had the same problem or knows how to solve it?

Thanks for any helps.

Did you edit the windows 7 host file and add a host to it?

You will need admin rights to do it


Add:  local.dev   # or what ever your virtualhost name is.

Could it be your ENVIRONMENT setting, or some config based on ENVIRONMENT? How are you detecting/setting the ENVIRONMENT in index.php?


You are right! My environment configuration was not checking the new url that I set the virtual host.


I check for production and testing server, and default to development. Then that won't matter, and it's also useful if you have multiple developers.

  case 'www.domain.com':
    define('ENVIRONMENT', 'production');
  case 'dev.domain.com':
    define('ENVIRONMENT', 'testing');
    define('ENVIRONMENT', 'development');

Theme © iAndrew 2016 - Forum software by © MyBB