0

Trying to connect with a database using PDO, I keep getting the error could "not find driver". Looking online, I'm guessing this is a configuration error, but I don't know how to fix it. Code:

try 
{
    $conn = new PDO("mysql:host=localhost;dbname=dubook", "root", "password");
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // more code here
}
catch(PDOException $e)
{
    echo "Connection to DB failed: " . $e->getMessage();
}
Mike
  • 517
  • 2
  • 5
  • 21
  • Works fine for me, can't reproduce your error. Make sure your show us your **full** and **real** code here – Rizier123 May 29 '15 at 16:48
  • Look in your php.ini file and uncomment all of the PDO drivers. Save the file and restart Apache. @Rizier123 you cannot reproduce because your system has the drivers installed. – Jay Blanchard May 29 '15 at 16:49
  • Depends more on your PHP setup / distribution. Unless you let on some details about that, we can't help either. – mario May 29 '15 at 16:49

0 Answers0