I uncommented the lines extension=php_pdo_mysql.dll
extension=php_pdo.dll
in my php.ini file but I still got the error
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'
None of the previous answers worked for me what should I do ?
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
try
{ $cnx = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password,$options);
}
catch(PDOException $ex)
{ die("Failed to connect to the database: " . $ex->getMessage());
}