mysql - Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in Undefined class constant (PHP 5.5.3) -
i have config file connects remote database, keep receiving error don't know how fix. in earlier versions meant bug assumed have been fixed 5.5.3.
<?php error_reporting(e_all); ini_set('display_errors', 'on'); $host = "localhost"; $dbname = "registration"; $username = "databaseeditor"; $password = "yolo10"; // 1002 = mysql_attr_init_command $options = array(pdo::mysql_attr_init_command => 'set names utf8'); try { $db = new pdo("mysql:host={$host};dbname={$dbname};charset=utf8", $username$ } catch(pdoexception $ex) { die("failed connect database: " . $ex->getmessage()); } $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); $db->setattribute(pdo::attr_default_fetch_mode, pdo::fetch_assoc); header('content-type: text/html; charset=utf-8'); echo "file works"; ?>
i keep receiving error "undefined class constant 'mysql_attr_init_command'"
. have tried use 1002 instead of 'mysql_attr_init_command' end error "syntax error, unexpected '1002' (t_lnumber)"
instead , have have installed newest php-mysql extension.
try editing php.ini:
on windows server can add following lines in php.ini
extension=php_pdo.dll extension=php_pdo_mysql.dll
on linux server can compile php following option --with-pdo-mysql
in php.ini, add following lines
extension=pdo.so extension=pdo_mysql.so
Comments
Post a Comment