title: PDO error in PHP - " Fatal error: Uncaught exception 'PDOException' with message 'could not find driver"
body: <p>I am using PDO to connect to database, but it returns this error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\AppServ\www\php-learn\cms project\lib\database.class.php:19 Stack trace: #0 C:\AppServ\www\php-learn\cms project\lib\database.class.php(19): PDO->__construct('mysql://hostnam...', 'root', '00000') #1 C:\AppServ\www\php-learn\cms project\config.php(49): database::get_instance() #2 {main} thrown in C:\AppServ\www\php-learn\cms project\lib\database.class.php on line 19</p>
  </blockquote>
  
  <h3>File <em>database.class.php</em>:</h3>
  
  <pre><code>class database
  {
      // static  تستخدم عندما نريد استخدام الكلاس دون انشاء اوجيكت
      // () $ ! ~ &amp; ^
      private static $db_connect;
  
      private function __construct()
      {} //
  
       // دالة لعمل اتصال ب قاعدة البيانتا
  
      // self ==&gt; تشير الى اللاكلاس نفسة
      public static function get_instance()
      {
          if(null === self::$db_connect){
  
              self::$db_connect = new PDO
              ('mysql://hostname='.DB_HOST.';dbname=' . DB_NAME,
               DB_USER,
               DB_PASS);
          }
          return self::$db_connect;
      }
  
  }
  </code></pre>
  
  <h3>File <em>config.php</em></h3>
  
  <pre><code>// Start buffering  ==&gt; the first function in the appliction
  ob_start();
  ini_set('display_errors', 1);
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_STRICT);
  ini_set('register_globals', 0);
  define("DS",DIRECTORY_SEPARATOR);
  define("PS",PATH_SEPARATOR); // WINDOWS = ; , LUNIX = ,
  define("HOST_NAME", 'http://' . $_SERVER['HTTP_HOST'] . '/'); // DOMAIN NAME
  
  // Paths
  define("APP_PATH", realpath(dirname(__file__)) . DS);
  define("TEMPLATE_PATH", APP_PATH . 'template' . DS);
  define("LIB_PATH", APP_PATH . 'lib' . PS);
  
  // Database
  define("DB_HOST", "localhost");
  define("DB_NAME", "cms_project");
  define("DB_USER", "root");
  define("DB_PASS", "00000");
  
  
  $newpath = get_include_path() . PS . LIB_PATH; // Define new path
  set_include_path($newpath);
  
  function __autoload($class)
  {
      require_once strtolower($class) . '.class.php';
  }
  
  $db_connect = database::get_instance();
  
  // End the buffering
  ob_flush();
  </code></pre>