无法理解错误:用户“Pratik”@“localhost”的访问被拒绝(使用密码:NO)进入php
首先我只是澄清问题。 我正在测试我网站的登录页面。 所以我有两个用于测试的登录文件,它们都包含相同的代码,但都保存在名为“signin.php”的不同位置。分别是“login.php”
问题是当我尝试从位于根文件夹(www)的“signin.php”登录时出现错误:用户“Pratik”@“localhost”的访问被拒绝(使用密码:NO)。在此我使用会话。
当我尝试从位于“c:\Temp\”文件夹中的“login.php”登录时,成功运行。 &根据我的代码创建用户名会话。
现在我再次尝试“signin.php”登录,然后这次登录成功。 但当会话过期时。 &我尝试再次从“signin.php”登录,它再次显示上述错误。
firstly i just clearify the problem.
i am testing the page of login of my website.
so i have two login files for testing that both contain same code but both are save in different place named "signin.php" & "login.php" resp.
the problem is when i try to login from "signin.php" which located in root folder(www) gives an error:Access denied for user 'Pratik'@'localhost' (using password: NO).in this i use session.
when i try to login from "login.php" which is located in "c:\Temp\" folder runs sucessfully. & create session of username as per my code.
now i try "signin.php" again for login, then this time it login sucessfully.
but when session expire. & i try to login from "signin.php" again it show above error again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它表示您正在使用
用户名:Pratik
和空密码访问数据库。如果没有任何密码,它将无法连接。
It's saying that you are accessing the database with
username: Pratik
and an empty password.It won't connect without any password.
检查您的
mysql_connect()
(或mysqli_connect()
)语句。如果您在多个地方使用它,显然其中一个或多个地方会有所不同,很可能是由于变量不在正确的范围内。例如:这将失败,因为您没有在函数内声明全局的 $password,因此您将得到一个空白密码和“使用密码:否”的错误。
Check your
mysql_connect()
(ormysqli_connect()
) statements. If you're using that in multiple places, obviously one or more of them differ somehow, most likely by a variable not being in the proper scope. For instance:This will fail as you have no declared $password to be global within the function, so you'll get a blank password and "Using password: NO" for an error.
这是因为您的文档根目录设置为
c:/Temp/
不是默认的c:/xampp/htdocs
(如果是 xampp)或c:/xampp/www/
(对于 WAMP)。要更改它,请转到
c:/xampp/apache/httpd.conf
或安装 apache 的位置。搜索文档根目录并将其设置为所需的路径。希望这有帮助..:)
This is because your document root is set to
c:/Temp/
not the defaultc:/xampp/htdocs
(in case of xampp) orc:/xampp/www/
(in case of WAMP).To change it go to
c:/xampp/apache/httpd.conf
or where ever your apache is installed. Search for the Document root and set to to desired path.Hope this was helpful.. :)