using PDO to connect Mysql database not working-Collection of common programming errors

  • Apache version: Apache/2.2.21 (Win32) PHP/5.3.10

  • in the php.ini file, I un-commented the line: extension=php_mysql.dll

    2a. phpinfo function showed ‘Loaded Configuration File’ location is C:\php\php.ini

    2b. PDO driver information showed by phpinfo function: under PDO section: PDO drivers–>Mysql (enabled) under PDO Driver for MySQL section: client API version–>mysqlnd 5.0.8-dev – 20102224 – $Revision: 321634 $ (enabled)

    Code I used to connection to the database


    $db_user = "uid"; $db_pass = "pd";


    $db_connect = new PDO('mysql:host=locahost; dbname=practice; charset=UTF-8', $db_user, $db_pass); if($db_connect){ print "connected to the db " . "
    "; }


    else{ print "error connects to the db. " . mysql_error(); }


    ?>

    The error message I received: