在第9行的C:\ webdev \ wamp \ www \ membershipSite \ classes \ Mysql.php中拒绝用户'username'@'localhost'的访问(使用密码:是) [英] Access denied for user 'username'@'localhost' (using password: YES) in C:\webdev\wamp\www\membershipSite\classes\Mysql.php on line 9

查看:79
本文介绍了在第9行的C:\ webdev \ wamp \ www \ membershipSite \ classes \ Mysql.php中拒绝用户'username'@'localhost'的访问(使用密码:是)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对所有这些都是新手,但我确实知道很多HTML/CSS.我想创建一个登录服务器,我从视频中获取了大部分代码.如果有人可以帮助我并进行详尽的解释,以便我能理解,将不胜感激.如果需要其他任何东西,我会很乐意将其发布.

I'm new to all of this but I do know a decent amount of HTML/CSS. I want to create a login server and I got most of the code from a video. If someone could help me and explain thoroughly so I can understand it would be greatly appreciated. If any other stuff is needed I will gladly post it.

<?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;
        }
    }

}
}

推荐答案

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

You need to grant permissions to the user@host in mysql. The grant command looks like

grant all privileges on YOURDB.* to
'YOURUSER'@'localhost' identified by 'YOURPASSWORD';

这篇关于在第9行的C:\ webdev \ wamp \ www \ membershipSite \ classes \ Mysql.php中拒绝用户'username'@'localhost'的访问(使用密码:是)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆