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

[eluser]Unknown[/eluser]
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.
#2

[eluser]InsiteFX[/eluser]
Did you edit the windows 7 host file and add a host to it?

You will need admin rights to do it

Code:
C:\Windows\System32\drivers\etc\hosts

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

[eluser]CroNiX[/eluser]
Could it be your ENVIRONMENT setting, or some config based on ENVIRONMENT? How are you detecting/setting the ENVIRONMENT in index.php?
#4

[eluser]Unknown[/eluser]
CroNiX.

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

Thankssss.
#5

[eluser]CroNiX[/eluser]
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.

Code:
switch($env)
{
  case 'www.domain.com':
    define('ENVIRONMENT', 'production');
    break;
  case 'dev.domain.com':
    define('ENVIRONMENT', 'testing');
    break;
  default:
    define('ENVIRONMENT', 'development');
    break;
}




Theme © iAndrew 2016 - Forum software by © MyBB