我突然明白了:
Warning: mysql_connect(): in C:\xampp\htdocs\login.php on line 12
cannot connect to server A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
我使用这段代码:
$dbhost="localhost";
$dbusername="dbusername";
$dbpassword="dbpassword";
$db_name="database";
mysql_connect("$dbhost", "$dbusername", "$dbpassword") or die("cannot connect to server". mysql_error());
mysql_select_db("$db_name") or die("cannot select db". mysql_error());
将主机更改为:
$dbhost="127.0.0.1";
一切正常。
为什么会这样?我怎样才能修复它像以前一样工作?谢谢!