2013-07-29 50 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

相關問題