這是一個非常簡單的MySQL查詢,我總是使用,但不知何故,我的一個網站腳本,它只是不起作用。不只是在網頁上的一個地方,但包括登錄和內容拉動的多個區域。我檢查了一切,包括,如果我有我的網站連接到MySQL數據庫服務器的正確與否(因爲登記工作,但登錄不)我做了一個快速測試,看看它是否工作正常:PHP不適用於MySQL查詢?
$usrn=$_POST['username'];
$pswd=$_POST['password'];
$query = "SELECT * FROM users WHERE user='$usrn' AND password='$pswd' DESC LIMIT 0,1";
$result = mysql_query($query);
$i=0;
while ($i < 1) {
[email protected]_result($result,$i,"user");
[email protected]_result($result,$i,"password");
echo $usrn."|".$usr."|".$pswd."|".$psw;
$i++;
}
在這腳本,它將輸出類似:
username||password|
這意味着沒有什麼可以輸出在$ usr和$ PSW通常在我的其他網站合作。
此外,當我包括以下內容:
$num = mysql_numrows($result);
它會給我一個錯誤信息:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /index.php on line 906
哇,這個代碼有太多的錯誤。你不僅[錯誤地存儲密碼](http://blog.moertel.com/articles/2006/12/15/never-store-passwords-in-a-database),你最好不要[Bobby Tables ](http://bobby-tables.com/)從未註冊過帳戶。 – 2011-04-09 04:31:07