I'm trying to run this simple query:
try {
$dsn = "mysql:host=localhost;dbname:mydb";
$PDO = new PDO($dsn, 'root', '');
$statement = $PDO->query("SELECT * FROM posts");
var_dump($statement);
} catch (PDOException $e) { exit($e->getMessage()); }
and this output:
bool(false)
I'm really getting mad about this error. I tried to run the query on my database. $PDO
is a PDO Object so technically it is connected to the database. It also seem that nothing gets wrong in all the pro functions. Running the copied and pasted query from $PDO->query()
on phpmyadmin return a list of 2 record. I don't know what to do seriously. I'm starting to pull my hair and hit the wall with the head (it's not a metaphor).
What am I doing wrong?