2011-09-03 92 views
1

我對PHP相當陌生,一直試圖使用PHP PDO進行簡單的登錄。當我嘗試登錄時,它一直拋出這個錯誤 - 調用未定義的函數RecordCount()。我的搜索沒有提供有關爲何發生這種情況的見解。我的代碼如下。任何洞察到哪裏看或爲什麼發生這將是值得讚賞的。謝謝!PHP錯誤調用未定義的函數RecordCount()

 <?php 
     include_once '../utils/dbcon.php'; 

     $stmt = $dbc->prepare("SELECT username,password FROM users where username = ? AND password = ?"); 

if ($stmt->execute(array($_GET['username'],$_GET['password']))) 
{ 


    if ($stmt.RecordCount()) 
     { 

     echo "record found"; 
     } 
    elseif(!$stmt.RecordCount()) 
      { 
     echo "No records found"; 
     } 

} 


     ?> 

回答

1

你的語法是錯誤的:

$stmt.RecordCount() 

應該

$stmt->RecordCount() 
+2

感謝您的快速響應。現在它正在拋出 - 調用未定義的方法PDOStatement :: RecordCount()。我將該方法更改爲rowcount(),現在似乎正在工作。我感謝幫助! –

相關問題