views:

42

answers:

2

i have following script in php to login to mysql

  $db_host="localhost";
  $db_user="root";
  $db_pass="123";

  $dbc=mysql_connect($db_host,$db_user,$db_pass) OR DIE (mysql_error());
  $dbs=mysql_select_db($db_name) OR DIE (mysql_error());    

this script was working fine, now i reinstall the O.S now i have windows 7 and iis7 and PHP Version 5.3.2 & mysql server 5.1 but now this script is not working and taking log time to execute.

Thanks

+2  A: 

use... $db_host="127.0.0.1"; or IP (e.g 192.168.1.2) instead of... $db_host="localhost";

kanenas.net
+2  A: 

On Windows 7 localhost resolves to ::1, and MySQL doesn't support IPv6 as far as I know.

Connecting directly to 127.0.0.1 resolves this problem; but you can edit the hosts file to resolve localhost to 127.0.0.1, then localhost will work too:

  1. Open C:\Windows\System32\drivers\etc\hosts
  2. Remove the following line, if present: ::1 localhost
  3. Add the following line, if not present: 127.0.0.1 localhost
RoliSoft