没用过pear DB,但就算你的数据库没有密码,
连接的时候也该多少给个空值当密码吧?

解决方案 »

  1.   

    同上
    <?php
    require_once 'DB.php';$user = 'foo';
    $pass = 'bar';
    $host = 'localhost';
    $db_name = 'clients_db';// Data Source Name: This is the universal connection string
    $dsn = "mysql://$user:$pass@$host/$db_name";// DB::connect will return a PEAR DB object on success
    // or an PEAR DB Error object on error$db = DB::connect($dsn);?>
      

  2.   

    唉,你这个例子我也有, 这个编译当然可以通过. 麻烦你query一下, 显示出来看看?$result = $db -> query ("select * from test");
    $row = $result -> fetchRow();echo "$row['name']";////////////////帮忙试一下,我刚学,  如果你用过, 应该可以马上看出问题来的, 多谢了
      

  3.   

    你的代码没有问题,但是
    由于你在$row = $result -> fetchRow();使用的是缺省参数,所以返回的数组只有下表,因此你用关联键当然取不到值。
    $row = $result->fetchrow(DB_FETCHMODE_ASSOC);
    echo $row['id'], "<br>";至于有出错信息,应该是你的pear有问题,请下载在最新的
      

  4.   

    重新下了php4.3.4就好了, 多谢. 看来5.0B2还是有问题.