Trouble connecting to MySQL database using PHP


I running through some exercises in the sitepoint book “PHP and MySQL: Novice to Ninja” (Chapter 4/connect/index.php). I opted to install PHP and MySQL separately instead of using XAMPP. I’m running on Windows 7, MySQL Server is 5.5, and PHP is (I think) 5.4.6. Web server is Apache 2.4.

I’m creating a connection using the following:
[FONT=Courier New]

  $pdo = new PDO('mysql:host=localhost;dbname=ijdb', 'ijdbuser', 'mypassword');
  $pdo->exec('SET NAMES "utf8"');
catch (PDOException $e)
  $output = 'Unable to connect to the database server: ' .
  include 'output.html.php';

$output = 'Database connection established.';
include 'output.html.php';


When running I get “Unable to connect to the database server: could not find driver”

I’ve been enjoying the book so far and was cruisin’ along until now. Any help would be appreciated. Am I missing a PHP module or something?


I have never used it but looking at pdo installation it says:

You may need to enable the PDO driver for your database of choice; consult the documentation for database-specific PDO drivers to find out more about that.

Thanks! The information in the link you provided worked. I had to enable the following in the php.ini file: