|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-06-13 07:40 UTC] progfr_list at gmx dot fr
Description:
------------
i have the message Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in "F:\....\fonction.php
i have check the php.ini and php_pdo_mysql.dll is loaded
Test script:
---------------
<?php
$DB_host='localhost';
$DB_base='db_base';
$DB_user='userlog';
$DB_pass='password';
try {
$connStr = 'mysql:host='.$DB_host.';dbname='.$DB_base; //Ligne 1
$arrExtraParam= array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"); //Error is in this line
$pdo = new PDO($connStr, $DB_user, $DB_pass, $arrExtraParam);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
$msg = 'ERREUR PDO dans ' . $e->getFile() . ' L.' . $e->getLine() . ' : ' . $e->getMessage();
die($msg);
}
Expected result:
----------------
Connect successfull to the database
Actual result:
--------------
Fatal error message
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 04:00:02 2025 UTC |
I can't reproduce this issue (php-7.0.0alpha1-nts-Win32-VC14-x64). When pdo_mysqli is not enabled, I get: | Fatal error: Uncaught EngineException: Undefined class constant | 'MYSQL_ATTR_INIT_COMMAND' ... When pdo_mysqli is enabled, the constant is defined (its value is 1002). Please double-check the error message (if "uncaught EngineException" is missing, somehow another PHP installation is interfering). And double-check that pdo_mysqli is really available (for instance, with extension_loaded('pdo_mysql') in the script).I have checked with extension_loaded('pdo_mysql') but i don't understand why pdo_mysql or pdo_mysqli is not loaded because is in php.ini