2013-07-29 42 views
0

我有XAMPP和我写了这个代码:梨无法正常工作:致命错误:类“PEAR_Error的”未找到

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>pear</title> 
</head> 

<body> 
<?php 
require 'DB.php'; 
$db = DB::connect('mysql://[email protected]/asd'); 
$query = "select * from asd"; 
$result = $db->query($query); 
while($raw = $result->fetchRow(DB_FETCHMODE_ASSOC)) 
{ 
echo $row['1'] , " "; 
echo $raw['2'], "<br>"; 
} 

?> 
</body> 
</html> 

但是当我打开本地主机上的文件上面写:

Fatal error: Class 'PEAR_Error' not found in C:\xampp\php\pear\DB.php on line 947. 

我重新安装了“DB”并检查是否安装了pear并且一切正常。

+0

可能会帮助您:http://stackoverflow.com/questions/62658/getting-pear-to-work-on-xampp-apache- mysql-stack-on-windows – Bora

+0

我已经看到,这不是问题,现在我已经在“DB.PHP”文件中搜索,我没有找到函数或类叫“pear_Error” – guy

回答

0

这不是一个直接的解决方案,但我建议你远离PEAR的DB并切换到PDO。这与您现在正在做的非常相似,并且得到了很好的支持,因为它是PHP的一部分。

一个良好的快速入门指南可以在这里找到:http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

+0

非常感谢你mutch。 我是用“DB”做的,因为我正在从书本上学习,并且他们说要做什么。 – guy

+0

这有点过时了。目前PDO是最好的选择。这很好,因为它允许您为所有数据库系统使用相同的PHP代码,并且它很容易安装。祝你好运! – Ambroos

+0

非常感谢你的配合!!!!!! – guy

相关问题