mysqli_connect():拒绝用户访问

时间:2019-05-29 04:02:22

标签: php mysql database hosting

我无法解决此问题。  我看到错误

  
      
  1. 警告:mysqli_connect拒绝用户'assamcre_deep'@'%'访问数据库
  2. 中的数据库“ assamcre_pubg”   
  3. 警告:mysqli_close()期望参数1为mysqli,在第47行的/home/assamcre/public_html/battleworld/data/db_connect.php中给出的布尔值
  4.   
<?php

/**
 * A class file to connect to database
 */
class DB_CONNECT
{

    public $con;

    // constructor
    function __construct()
    {
        // connecting to database
        $this->connect();
    }

    // destructor
    function __destruct()
    {
        // closing db connection
        $this->close();
    }

    /**
     * Function to connect with database
     */
    function connect()
    {
        // import database connection variables
        require_once __DIR__ . '/db_config.php';

        global $con;

        // Connecting to mysql database
        $con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE) or die(mysql_error());

        // Selecing database
        // $db = mysqli_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());

        // returing connection cursor
        return $con;
    }

    /**
     * Function to close db connection
     */
    function close()
    {
        global $con;
        // closing db connection
        mysqli_close($con);
    }
}

0 个答案:

没有答案