my localhost is saying error like Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocsegistration\includes\db.php on line 3
on the browser I have all things done here's the image of the error in browser.
1: here is the image which is facing the error
and also if I am doing something wrong in my code editor then here's the image of the db.php db.php files code
This is how you should connect your database using mysqli :
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "dbname";
$db = new mysqli($servername, $username, $password, $dbname);
?>
Edit : Why the down vote ?
You may have an invalid password.
Edit: To me it looks like you're failing to actually pass parameters to the connection function, are you including / importing the variables?
your DB_HOST is your mysql server ip (most time is localhost)
your DB_USER is your User of Mysql (most time is root)
your DB_PASS is your Password of Mysql User (most time is none)
your DB_NAME is your name of your database in Mysql server
You have passed invalid credentials (user name and/or password) when trying to connect to the database. What to pass can't be answered here because only you (the database administrator) would know about the existing user accounts.
To add an user account to a MySQL database see MySQL :: MySQL 5.7 Reference Manual :: 6.3.2 Adding User Accounts[^]. This requires connecting as root and providing the root password if one has been set.
The second is a result of the first and of using the wrong error function. For mysqli_connect(), you have to call PHP: mysqli::$connect_error - Manual[^] instead of mysqli_error() upon errors: Hide Copy Code $connection = mysqli_connect ($host, $user, $password) or die('Not connected : Ah sh*t ' . mysqli_connect_error());
This issue is tricky. But, how i went around it was straightforward. in your mysqli_connect(_,_,_,_)
arrange them in this order of "localhost"
, "user"
, "password"
, "database_name"
;