I know this question has been asked before but the answers found don't help me to find why my code is not working.
I specify that I use WAMP under Windows, that the name of my database is "myapp" and I am looking for the results of the "posts" table.
My SQL query:
"SELECT * FROM `posts`"
works with phpMyAdmin.
Nevertheless; I have the message indicated in the title.
My code:
$pdo = new PDO("mysql:host = localhost; dbname = myapp", 'root', '');
$sql = "SELECT * FROM `posts`";
$query = $pdo->query($sql);
var_dump($query);
$posts = $query->fetchAll();
For information,
var_dump($query);
return false
Please help me :(
Thanks in advance