开发者

cant undrstand the error :Access denied for user 'Pratik'@'localhost' (using password: NO) got in php

开发者 https://www.devze.com 2023-01-13 06:13 出处:网络
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

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.


It's saying that you are accessing the database with username: Pratik and an empty password.

It won't connect without any password.


Check your mysql_connect() (or mysqli_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:

$user = 'Pratik'
$host = 'localhost';
$password = '...';

function db_conn() {
    global $user, $host;
    $con = mysql_connect($host, $user, $password);
}

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.


This is because your document root is set to c:/Temp/ not the default c:/xampp/htdocs(in case of xampp) or c:/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.. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消