不是吧,楼上的!我怀疑你用过pear没有

解决方案 »

  1.   

    新问题出来了:
    如果一个页面上只有:
    <?
    require_once("DB.php"); 
    ?>
    执行则会报错:可是页面上却显示:Fatal error: Class 'PEAR_Error' not found in C:\php\php5\PEAR\DB.php on line 868可是如果我把页面都写全,也就是:
    <?
    //1.1 连接和关闭数据库 
    require_once 'PEAR/DB.php'; $user = 'root'; 
    $pass = 'root'; 
    $host = 'localhost'; 
    $db_name = 'db_test'; 
      
    // 这是统一的连接字符串形式: 
    $dsn = "mysql://$user:$pass@$host/$db_name"; //连接成功则返回一个正确的数据库指针 
    //反之如果连接失败则返回错误的数据库指针 
    //如果你想开启mysql持久连接 
    //设置第二个参数为真 
    // $db = DB::connect($dsn, true);
    $db = DB::connect($dsn); 
    echo($db);
    // 使用函数DB::isError查看返回的数据库连接指针是否正确 
    if (DB::isError($db)) { 
      die ($db->getMessage()); 
    } $sql = "select * from test"; 
    //如果查询语句是 "SELECT"之类的, $db->query 将返回 
    // 查询结果对象 
    // 如果失败则返回 DB Error object. 
    $result = $db->query($sql); 
    // 总是检查指针是否正确 
    if (DB::isError($result)) { 
            die ($result->getMessage()); 

    // 得到每行记录 
    while ($row = $result->fetchRow()) { 
        $id = $row[0]; 
        echo($id);

    // 用disconnect()关闭数据库的连接 
    $db->disconnect(); ?>
    执行时页面一片空白,那个白啊!!!!如果我故意把$pass = 'root'; 这个pass写成不正确的,执行,仍是一片空白,也不报错,何解??有经验的来帮帮忙了
      

  2.   

    刚刚我重新安装了下PEARrequire_once("DB.php"); 没有任何问题,倒是 require_once 'PEAR/DB.php';  有问题,看看你的include_path有问题没有,用你的代码,只改 require_once 'PEAR/DB.php';后会报错 Object id #2DB Error: connect failed
      

  3.   

    多谢楼上的,问题解决了,怎么说呢,也许很弱智,也许不说可能一下子也想不到。
    我把我写的这个php文件当时随意的命名为了“pear.php”,由于在php.ini中指定了pear的路径,自然与系统路径中的pear.php冲突了,呵呵!