Undefined Class Constant 'Mysql_Attr_Init_Command' with Pdo

Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in Undefined class constant (PHP 5.5.3)

Try editing your php.ini:

On a windows server you can add the following lines in your php.ini

 extension=php_pdo.dll
extension=php_pdo_mysql.dll

On a Linux server you can compile php with the following option --with-pdo-mysql

In your php.ini, add the following lines

 extension=pdo.so
extension=pdo_mysql.so

undefined class constant 'mysql_attr_init_command' in MAMP using php 5.4.4

Check out this DSN:

$dsn = 'mysql:dbname=testdb;host=127.0.0.1;charset=utf8';

Instead of MySQL attr init command.

Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'; phpinfo shows no PDO extensions, but php -i (php -m) do

Thanks to Mark B. He suggested the right answer in the comments.

The .php file with phpinfo() in the browser shows that php loaded php.ini from C:\Windows, but there is no php.ini under my C:\Windows. The reason why it's like this is that php.ini overrides php's compiled-in defaults. So I saw the compiled-in defaults with phpinfo().

I used the PHPIniDir in my virtual host to point to the actual folder with the php.ini file. Then I saw the PDO extensions, and everything works fine.

PS: Marc, if you post your answer, I'll remove mine and accept yours.

ratchet PHP Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in

In your php.ini file, you should have the following line (uncommented):

extension=php_pdo_mysql.dll on Windows
extension=php_pdo_mysql.so on Linux/Mac

Then restart apache and try your code



Related Topics



Leave a reply



Submit