程序为:  $db = new mysqli('localhost:3306','bookorama','bookorama123','books');提示:PHP Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'bookorama'@'localhost' (using password: YES) in D:\php网站\results.php on line 24 PHP Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in D:\php网站\results.php on line 36 PHP Notice: Trying to get property of non-object in D:\php网站\results.php on line 38 PHP Fatal error: Call to a member function free() on a non-object in D:\php网站\results.php on line 55 

解决方案 »

  1.   

    没有错啊,不知道是不是'localhost:3306'的问题,我在iis上是设的8080,这个端口是写数据库的端口还是iis的端口
      

  2.   

    $db = new mysqli('localhost','bookorama','bookorama123','books');不需要加3306吧,这里是数据库的端口
      

  3.   


    header("content-type:text/html;charset:utf-8");class MysqlConn{
    const SERVERNAME = "localhost:3306";
    const USERNAME = "root";
    const PASSWORD = "111111";
    const MYSQLDB = "MovieSpecialtyArea"; function conn(){
    //常量与静态变量一样,用"self::"调用
    $mysqli = new mysqli(self::SERVERNAME,self::USERNAME,self::PASSWORD,self::MYSQLDB);
    //检查数据库连接
    if (mysqli_connect_error()){
    printf("数据库连接失败:",mysqli_connect_error());
    exit;
    }else{
    //返回结果,为了实例化对象的调用
    return $mysqli;
    } }}
      

  4.   

    Access denied for user 'bookorama'@'localhost' (using password: YES)mysql已经连接成功了, 所以localhost:3306是正确的不过后面的用户名密码错误,或者部署的服务器没有在mysql中被授权。 
    需要到mysql中进行grant操作。To LZ,联系你的DBA吧,这个操作对于你来说有点难...
      

  5.   

    PHP Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) in D:\php网站\2.php on line 19 
      

  6.   

    这个明显就是帐号未通过验证。
    密码错了吧
    服务器是否允许localhost?
      

  7.   

    或者是要访问的数据库没有对用户授权。用grant获得授权