2015-04-03 95 views
-2

我已經使用PHP和MySQL做了一個登錄表單。但是,當我輸入錯誤的登錄信息時,我遇到了一個錯誤。PHP登錄不執行其他

<?php 

    while($row = mysql_fetch_array($result)) 
    { 
    if($result) 
     { 
     header('Location: supplementsstore.php'); 
     } 
    else 
     { 
     header('Location: logon.php'); 
     } 
    } 

?> 

if作品它應該,但它不會做else聲明。 我試圖改變其他!$result,但也沒有工作。

+3

* 「我在一個錯誤運行」 * - 正?選擇1001個可能的原因。 *完全不清楚你問什麼*。 – 2015-04-03 18:15:00

+1

你爲什麼要做'if($ result)'? – 2015-04-03 18:15:50

+0

什麼是$結果我們需要更多詳細信息 – TheSk8rJesus 2015-04-03 18:16:50

回答

2

如果if($result)被評估爲false,則永不輸入while循環。

所以嘗試:

if(count($row) > 0) 

而不是

if($result){} 
+1

即使用最大最長的刀,我絕對不會在黑暗中刺中。但是,你可能是對的。讓我們來看看OP要說些什麼;-)可能是個幸運的人。 – 2015-04-03 18:18:41

0
if($row = mysql_fetch_array($result)) 
{ 
header('Location: supplementsstore.php'); 
} 
else 
{ 
header('Location: logon.php'); 
}