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
Why Does PHP Convert a String with the Letter E into a Number
Php.Ini Changes, But Not Effective on Ubuntu
How to Convert a String to JSON Object in PHP
PHP - How to Build Tree Structure List
A Better Approach Than Storing MySQL Password in Plain Text in Config File
Is It Recommended to Store PHP Sessions in Memcache
Request Headers Bag Is Missing Authorization Header in Symfony 2
How to Create Installer for Website. PHP MySQL
PHP 5.4 - 'Closure $This Support'
Convert Jpg/Gif Image to Png in PHP
PHP Cli: How to Read a Single Character of Input from the Tty (Without Waiting for the Enter Key)
How to Convert Seconds to Time Format
How to Fix the "Base Table or View Not Found: 1146" Error When Running 'PHP Artisan Migrate' Command
Parse JSON String Contents into PHP Array
$_Files Field 'Tmp_Name' Has No Value on .Jpg File Extension