0

我已经编写了这些代码。但他们没有很好地工作。它有一些像这样的错误:

Warning: mysqli_connect() [function.mysqli-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www...

有时会显示T_EXIT错误。我的问题在于“或死”命令。假设它无法连接到数据库。然后它应该打开“或死亡”并终止程序。但它没有这样做。我该如何解决?

$dbc = mysqli_connect('localhost', 'user', 'pass', 'table')
 or die('Error connecting to MySQL server.');
4

1 回答 1

0

My problem is in "or die" command. Suppose it cannot connect to database. Then it should switch on "or die" & terminates the the program.

答案直接来自PHP 手册

$link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');

if (!$link) {
    die('Connect Error (' . mysqli_connect_errno() . ') '.mysqli_connect_error());
}
于 2013-03-21T08:29:30.427 回答