我正在尝试连接到我的数据库,但显示“连接到数据库失败”。有人知道这个问题
<?php
$db_host = "localhost";
$db_user = "my_login";
$db_pass = "123456";
$db_name = "my_login";
$con = mysqli_connect($db_host,$db_user,$db_pass,$db_name);
if(mysqli_connect_error()){
echo 'connect to database failed';
}
?>
答案 0 :(得分:-1)
您的代码已重写:
$con = mysqli_connect($db_host,$db_user,$db_pass,$db_name);
if (!$con)
{
echo 'connect to database failed: '.mysqli_connect_error();
die(1);
}
现在您看到错误原因了!