我登录系统的查询在本地运行正常,但在服务器上传时。它不会在PHP中返回任何内容。这是查询:
"SELECT `UserID`
FROM `" . DB_NAME . "`.`Login`
WHERE `UserName` = '" . $UserName . "'
AND `UserPassword` = '" . $Password . "';"
...这是我的PHP代码:
$UserName = $_POST['txtUserName'];
$Password = md5($_POST['txtPassword']);
$qry = "SELECT `UserID`
FROM `" . DB_NAME . "`.`Login`
WHERE `UserName` = '" . $UserName . "'
AND `UserPassword` = '" . $Password . "';";
$result = mysql_query($qry);
session_start();
if ($result) {
if (mysql_num_rows($result) > 0) {
//Login Successful
session_regenerate_id();
$User = mysql_fetch_assoc($result);
$_SESSION['UserID'] = $User['UserID'];
session_write_close();
mysql_close();
exit();
} else {
//Login failed
mysql_close();
die('Invalid UserName and Password combination...');
}
} else {
mysql_close();
die('Query failed...' . mysql_error());
}
返回的输出是:
Query failed...
答案 0 :(得分:1)
As no one has responded in the answers area. I want to reply the post myself for future clarification of anyone arriving here and seeing this post.
问题在于表格的名称。我将其拼写为Login
,而原始表格名称为login
。
我不知道为什么这个东西只出现在服务器上。即,它在我的机器上本地工作正常,但问题仅在服务器上到达。
我通过在查询中重命名表名来修复此问题。
HTH,谢谢,