0

首先,我只是澄清问题。我正在测试我网站的登录页面。所以我有两个用于测试的登录文件,它们都包含相同的代码,但都保存在名为“signin.php”和“login.php”的不同位置。

问题是当我尝试从位于根文件夹(www)中的“signin.php”登录时出现错误:用户'Pratik'@'localhost'的访问被拒绝(使用密码:NO)。在这个我使用会话。

当我尝试从位于“c:\Temp\”文件夹中的“login.php”登录时成功运行。并根据我的代码创建用户名会话。

现在我再次尝试“signin.php”登录,这次它成功登录。但是当会话到期时。&我尝试再次从“signin.php”登录它再次显示上述错误。

4

3 回答 3

1

这表示您正在使用username: Pratik空密码访问数据库。

没有密码就无法连接。

于 2010-08-28T19:07:13.317 回答
0

检查您的mysql_connect()(或mysqli_connect())陈述。如果您在多个地方使用它,显然它们中的一个或多个会有所不同,很可能是因为变量不在正确的范围内。例如:

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

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

这将失败,因为您没有在函数中声明 $password 是全局的,因此您将获得一个空白密码和“使用密码:否”错误。

于 2010-08-28T19:12:54.927 回答
0

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.. :)

于 2010-08-28T19:53:54.630 回答