简体   繁体   English

梨不能正常工作:致命错误:找不到类“ PEAR_Error”

[英]pear isn't working properly: Fatal error: Class 'PEAR_Error' not found

I have xampp and I wrote this code: 我有xampp,我写了这段代码:

    <!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://root@localhost/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>

But when I opened the file on localhost it wrote: 但是,当我在本地主机上打开文件时,它写道:

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

I reinstalled "DB" and checked if pear is installed and everything was ok. 我重新安装了“ DB”,并检查是否安装了pear,并且一切正常。

It's not a direct solution, but I suggest you move away from PEAR's DB and switch to PDO. 这不是直接的解决方案,但我建议您离开PEAR的DB并改用PDO。 It's very similar to what you're doing now and well-supported since it's a part of PHP. 由于它是PHP的一部分,因此与您现在正在做的事情和得到良好支持的情况非常相似。

A good quick-start guide can be found here: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers 一个很好的快速入门指南可以在这里找到: http : //wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM