0

I've searched for an answer before but nothing seems to work. Thats the code I use to set up the connection.

<?php 

    // connect to the database
    $conn = mysqli_connect('localhost', 'user', '123456', 'user_data');

    // check connection
    if(!$conn){
        echo 'Connection error: '. mysqli_connect_error();
    }

?>

And that's the error message I recieve as soon as I try to open the file itself or try to include it anywhere else.

Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'user'@'localhost' (using password: YES) in C:\xampp\htdocs\tutorials\Garten\config\db_connect.php:4 Stack trace: #0 C:\xampp\htdocs\tutorials\Garten\config\db_connect.php(4): mysqli_connect('localhost', 'user', '123456', 'user_data') #1 {main} thrown in C:\xampp\htdocs\tutorials\Garten\config\db_connect.php on line 4

Can anyone help me fix the probleme, that would be great.

Samortal
  • 9
  • 2
  • 1
    “Access denied for user” can mean several things. The most common problem is that the password is incorrect. Have you triple-checked the username and password values? – rickdenhaan Aug 26 '22 at 22:41
  • 1
    IN 20+ years, I have only seen that error when there was a typo in the parameters. Your syntax is correct. as long a user_data is the name of the database and not a table. – Misunderstood Aug 27 '22 at 02:13
  • 1
    Can you log in to the localhost DB server using another Mysql client, for instance, mysql_cli with the same account? – Jun Pan Aug 27 '22 at 03:04
  • What do you see when you type in **localhost** in the browser? – Rohit Gupta Aug 27 '22 at 05:25

0 Answers0