views:

35

answers:

3

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.

i cants uerstand what is going on. plz help me.

+1  A: 

its saying that u r accessing the db using username: Pratik with blank password.... it'll not connect without any password...

Vaibhav Gupta
actually my db username is root mysql_select_db("Admin") or die(mysql_error());
Pratikg88
then check ur db privileges for the root user...
Vaibhav Gupta
Gaaaah. Do NOT use 'root' as your database account. NEVER EVER USE ROOT AS YOUR DATABASE ACCOUNT. Create a new user with just the privileges you require for your app.
Marc B
A: 

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.

Marc B
@Marc B : as i told you my other login file works fine. mysql_select_db("Admin") or die(mysql_error());
Pratikg88
A: 

This is because ur 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 ur apache is installed. Search for the Document root and set to to desired path.

Hope this was helpful.. :)

Anurag