'What Should I do I am getting Fatal Error from this code?
Getting this error:-
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) in C:\WEB-PROJECT\xampp\htdocs\facebook\core\database\connection.php:8 Stack trace: #0 C:\WEB-PROJECT\xampp\htdocs\facebook\core\database\connection.php(8): PDO->__construct('mysql:host=127....', 'root', '') #1 C:\WEB-PROJECT\xampp\htdocs\facebook\core\load.php(3): include('C:\WEB-PROJECT\...') #2 C:\WEB-PROJECT\xampp\htdocs\facebook\sign.php(4): require('C:\WEB-PROJECT\...') #3 {main} thrown in C:\WEB-PROJECT\xampp\htdocs\facebook\core\database\connection.php on line 8
From this code:- <?php
$hostDetails = 'mysql:host=127.0.0.1; dbname=facebook; charset=utf8mb4';
$userAdmin = 'root';
$pass = '';
try{
$pdo = new PDO($hostDetails,$userAdmin,$pass);
} catch(PDOExecption $e){
echo 'Connection error!' . $e->getMessage();
}
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|