在第9行的C:\ webdev\wamp\www\membershipSite\classes\Mysql.php中拒绝用户'用户名'@'localhost'(使用密码:YES)

The*_*ola 5 mysql access-denied

我是所有这一切的新手,但我确实知道相当数量的HTML/CSS.我想创建一个登录服务器,我从视频中获得了大部分代码.如果有人可以帮助我并彻底解释,那么我可以理解,我将不胜感激.如果需要任何其他东西我会很乐意发布它.

<?php

require_once 'includes/constants.php';

class Mysql {
private $conn;

function _construct() {
    $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.');
}

function verify_Username_and_Pass($un, $pwd) {

    $query = "SELECT *
            FROM users
            WHERE username = ? AND password = ?
            LIMIT 1";

    if($stmt = $this->conn->prepare($query)) {
        $stmt->bind_param('ss', $un, $pwd);
        $stmt->execute();

        if($stmt->fetch()) {
            $stmt->close();
            return true;
        }
    }

}
}
Run Code Online (Sandbox Code Playgroud)

Kev*_*ert 9

您需要在mysql中向user @ host授予权限.grant命令看起来像

grant all privileges on YOURDB.* to
'YOURUSER'@'localhost' identified by 'YOURPASSWORD';
Run Code Online (Sandbox Code Playgroud)