PHP5.3提示Fatal error: Undefined class constant MYSQL_ATTR_INIT_COMMAND
今天帮朋友做了个简单的信息录入程序,本地调试一切OK。
传到朋友的服务器后,死活不能用,一涉及数据库的读写就出现一个Fatal error.
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' 查来查去,原来是PHP5.3.0的BUG
http://bugs.php.net/bug.php?id=47224
解决办法有两种,一是改代码
$pdb = new PDO("mysql:host=localhost;dbname=test", 'root');
$pdb->exec("SET NAMES utf8");
二就是升级你的PHP到更高的版本喽~~
所以,要从PHP5.2升级到PHP5.3的同学,要注意一下你的代码呀~~
您可能感兴趣的文章:
PHP5.3提示Fatal error: Undefined class constant MYSQL_ATTR_INIT_COMMAND
php出现Notice : Use of undefined constant 的解决方法
PHP运行出现Notice : Use of undefined constant 的解决方法
php提示Fatal error: Call to undefined function openssl_x509_parse()
PHP匿名函数与注意事项详解
帝国cms设置及服务器本身问题引起的错误提示解决方法
PHP类 const常量访问方法例子
关于PHP中Exception、Error Handler的细节以及实例详解
Fatal error: Maximum execution time of 30 错误解决办法
php分页出现Fatal error错误的解决方法