我在给定的链接中使用这样的php mysql包装器类......但是我无法连接到db

时间:2014-08-08 09:46:50

标签: php mysql oop

class DB
  {

    var $defaultDebug = false;


    var $mtStart;

    var $nbQueries;

    var $lastResult;


    function DB($base, $server, $user, $pass)
    {
      $this->mtStart    = $this->getMicroTime();
      $this->nbQueries  = 0;
      $this->lastResult = NULL;
      mysql_connect($server, $user, $pass) or die('Server connexion not possible.');
      mysql_select_db($base)               or die('Database connexion not possible.');
    }

}

这是我正在使用的db类。我尝试从这个类创建一个新对象,如$db=new DB("dbname","localhost","user","rootwdp");,但我总是得到错误无法连接到数据库..这里有什么问题。有人可以帮忙吗?

在此之后我在db类中创建了四个变量。然后我实例化了一个新的对象,如$ dd-> new DB();并向他们添加了变量,如$ this-> dbname =" dbname",$ this-> server =" localhost"等等。它还说警告:缺少DB :: DB()的参数1,在第4行的D:\ www \ webroot \ oops \ test.php中调用,并在D:\ www \ webroot \ oops \ db中定义第34行的.class.php

警告:缺少DB :: DB()的参数2,在第4行的D:\ www \ webroot \ oops \ test.php中调用,并在D:\ www \ webroot \ oops \ db.class.php中定义在第34行

警告:缺少DB :: DB()的参数3,在第4行的D:\ www \ webroot \ oops \ test.php中调用,并在D:\ www \ webroot \ oops \ db.class.php中定义在第34行

警告:缺少DB :: DB()的参数4,在第4行的D:\ www \ webroot \ oops \ test.php中调用,并在D:\ www \ webroot \ oops \ db.class.php中定义在第34行

警告:mysql_connect()[function.mysql-connect]:拒绝访问用户' ODBC' @' localhost' (使用密码:NO)在第39行的D:\ www \ webroot \ oops \ db.class.php中 服务器连接不可能.34是我编辑器的方法起点。服务器连接不可能。问题是什么?问题在哪里

0 个答案:

没有答案