So I made an app which has a log in script and I'm using a WAMP server. I want to put users into the MySql database. When I run my script using a log in form I get this error: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO). I don't know whats the problem.
I know that many commenter have told me that the user has a password. I know that. The problem is that even if I use the password in my password variable(as you can see in my code; I'm using a connect function to connect to the database). It still doesn't connect.
public function connect()
{
try {
$username = "root";
$password = "";
$db = new PDO('mysql:host=localhost;dbname=readersnewcenter', $username, $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $db;
} catch (PDOException $e) {
print "Error: " . $e->getMessage() . "<br/>";
die();
// throw exception
}