PHP错误调用未定义的函数RecordCount()

问题描述:

我对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"; 
     } 

} 


     ?> 

你的语法是错误的:

$stmt.RecordCount() 

应该

$stmt->RecordCount() 
+2

感谢您的快速响应。现在它正在抛出 - 调用未定义的方法PDOStatement :: RecordCount()。我将该方法更改为rowcount(),现在似乎正在工作。我感谢帮助! –