Heim  >  Artikel  >  php教程  >  PHP5.3提示Fatal error: Undefined class constant MYSQL_ATTR_INIT_COMMAND

PHP5.3提示Fatal error: Undefined class constant MYSQL_ATTR_INIT_COMMAND

WBOY
WBOYOriginal
2016-05-24 08:59:441737Durchsuche

下面来看看在使用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的同学,要注意一下你的代码呀~~

文章网址:

随意转载^^但请附上教程地址。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn