Db-Connection错误

时间:2016-01-26 16:46:50

标签: php mysql database phpmyadmin

我在尝试连接数据库时遇到这些错误:

  

警告:mysqli_connect():( HY000 / 1045):第2行的C:\ xampp \ htdocs \ Vehicleshowroom \ dbconnection.php中的用户'root'@'localhost'(使用密码:YES)拒绝访问

     

警告:mysqli_error()期望在第5行的C:\ xampp \ htdocs \ Vehicleshowroom \ dbconnection.php中给出1个参数0   无法连接

代码是

<?php 
    $con=mysqli_connect("localhost","root", "technology","vehicleshowroom"); 
    if(!$con) { 
       die("could not connect".mysqli_error()); 
    } 
?>

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
<?php

$con = mysqli_connect("localhost", "root", "", "vehicleshowroom");

if (mysqli_connect_errno()) {
    echo mysqli_connect_error();
    exit();
}
?>
&#13;
&#13;
&#13;