在PHP中连接数据库时出错?

时间:2016-03-18 11:43:24

标签: php mysql mysqli localhost

当我尝试连接到我的mysql数据库时出现错误,我不知道如何修复它们:

Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. in C:\xampp\htdocs\first.php on line 6

Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. in C:\xampp\htdocs\first.php on line 6

Warning: mysqli_errno() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\first.php on line 7

Fatal error: Uncaught Error: Call to undefined function mysql_close() in C:\xampp\htdocs\first.php:16 Stack trace: #0 {main} thrown in C:\xampp\htdocs\first.php on line 16

继承源代码。

<?php
$dbhost = "localhost";
$dbuser = "widget_cms";
$dbpass = "";
$dbname = "wigetcorp";
$datab = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if(mysqli_errno()){
    die("Database connection failed: " . mysqli_connect_error() . " (" . mysqli_connect_errno() . " )");
}
?>
<html>
<body>
</body>
</html>
<?php
mysql_close($datab);

?>

密码不是空白,我只是把它放在这里。

0 个答案:

没有答案