php
  • sql
  • 2011-12-28 80 views 0 likes 
    0

    我寫了下面的代碼,當它運行時,無論SQL查詢是什麼,我都會得到「錯誤:查詢是空的」。我知道生成的SQL很好,因爲如果我將它粘貼到SQL數據庫中,它將返回行。記錄集的PHP代碼已從其他工作正常的頁面粘貼,因此我無法查看錯誤的位置。PHP記錄集返回「錯誤:查詢是空的」

    殼體4://檢查是否用戶先前已加載的清單

    $mySQL = "SELECT * FROM tools_userChklists WHERE chklistID = '" . $_GET['chklistID'] . "'"; 
          echo $mySQL; 
        $query_rsChecklists = $mySQL; 
        $rsChecklists = mysql_query($query_rsChecklists) or die(mysql_error()); 
        $row_rsChecklists = mysql_fetch_assoc($rsChecklists); 
        $totalRows_rsChecklists = mysql_num_rows($rsChecklists); 
    
        if ($totalRows_rsChecklists <> 0){ 
         //the user has already opened this checklist 
         $_SESSION['redirectorAction'] = ""; 
         $_SESSION['redirectorAction'] = "Location: actions.php?action=5&chklistID=" . $_GET['chklistID']; 
        }else{ 
         //the user has never opened this checklist 
         $_SESSION['redirectorAction'] = ""; 
         $_SESSION['redirectorAction'] = "Location: actions.php?action=6&chklistID=" . $_GET['chklistID']; 
        } 
    break; 
    

    任何幫助理解。謝謝。

    回答

    0

    $ row_rsChecklists是結果資源,並且您在rsChecklists上有numrows。我建議使用真正簡單的單詞,例如「行」來進行短分組工作。

    +0

    如前所述,我已經使用相同的格式代碼記錄幾年現在沒有問題。我會試一試,但我不太確定它會有所作爲。感謝您的輸入。 – MingMing 2011-12-29 23:23:48

    相關問題