OS: Debian 8 "Jesse", PHP 7.0, mySQL 5.5.53
As the title says, I've created a PDO object trying to demo the basic functionality to myself with locahost, and it always throws an exception regardless of whether or not the database request is correct or not. Here's the code, with user and password as stand-ins for the real data:
<?php
try {
$pdo = new PDO('mysql:host=127.0.0.1;dbname=myToDo', 'user', 'password');
}
catch (PDOException $e) {
die('Could not connect.');
}
?>
When I run this on a test server (port 8888), whether the dbname I feed it is right or wrong, it always throws the exception. My code looks identical to that demonstrated on the Laracast excepting that his profile has no password and mine does. But I've confirmed I'm entering the password exactly as I configured it in mySQL.
EDIT: ISSUE RESOLVED
After following the advice in the comments, I got a new error message that I was able to use googlefu on and found that I needed to manually install the packages containing the pdo extension like so:
apt-get install php7.0-mysql