Hello everyone am trying to connect to MySQL database but getting this error:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) Error: Could not establish connection.Access denied for user 'root'@'localhost' (using password: YES). Here is my code:
<?php
$host = "localhost";
$db = "resumedb";
$username = "root";
$password = "sa";
$phpConnect = mysqli_connect($host, $username, $db, $password);
//checking the if connection.
if($phpConnect === false)
{
die("Error: Could not establish connection.".mysqli_connect_error());
}
?>
The right syntax is: mysqli_connect("myhost","myuser","mypassw","mybd")
so try:
$phpConnect = mysqli_connect($host, $username, $password, $db);
Basically If you are the newbee in PHP so you should
1.first start the Xamp/Wamp service.
2.else db credentials for password should be $password = "".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.