For everybody that tests on localhost with windows(7)

This problem is not Codeigniter related, but I'm posting this as a heads up.

If you are testing PHP scripts on windows 7 and all goes well until you try to load your database class, your page doesn't load and just hangs there and times out, resulting in a blank page, then this is for you.

The cause
Localhost does not point to with windows7. In previous version of windows this was the case, but in windows7 it doesn't. Because of this; PHP cannot find the mysql (local)host!

However, you can easily do this yourself Smile
Add the following line to your hosts file (usually located at C:\Windows\System32\drivers\etc):
Code:       localhost

And you are done!

If you are using easyPHP for example, like me, you can now connect to your database with:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "databasename";

I hope this will help someone.


I would suggest NOT to use 'localhost' (whether or not your OS supports it), but go for something like 'my.laptop.local'.

If you use the session library, you will run into problems when using 'localhost' as hostname for your site, as it is an illegal domainname for cookies. Some browsers will therefore reject these cookies, causing all kinds of issues.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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