Fatal error: Class 'PDO' not found in E:\Projects\Php\test\newfile.php on line 2
这个程序只有一行代码,那就是$pdo=newPDO("mysql:host=localhost;dbname=openwebsa","root","123");请会php...
这个程序只有一行代码,那就是$pdo = new PDO("mysql:host=localhost;dbname=openwebsa","root","123");请会php的朋友帮忙看下,谢谢了!
展开
2个回答
展开全部
看看PDO的类加载进来没???
<?php
$dsn = "mysql:host=localhost;dbname=test";
$db = new PDO($dsn, 'root', '');
$count = $db->exec("INSERT INTO foo SET name = 'heiyeluren',gender='男',time=NOW()");
echo $count;
$db = null;
?>
<?php
$dsn = "mysql:host=localhost;dbname=test";
$db = new PDO($dsn, 'root', '');
$count = $db->exec("INSERT INTO foo SET name = 'heiyeluren',gender='男',time=NOW()");
echo $count;
$db = null;
?>
追问
运行这些,还是报一样的错误,问题怎么解决?
追答
你的PHP里有加载pdo.dll吗?
下面有一堆类似 ;extension=php_mbstring.dll 的东西,这里就是PHP扩展加载的配置了,我们再最后面添加上我们PDO的扩展:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pdo_mssql.dll
extension=php_pdo_odbc.dll
extension=php_pdo_firebird.dll
;extension=php_pdo_oci8.dll
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询