我不确定为什么这不起作用:
if($strFilterByStatus != 'all' && $strFilterByYear == 'all' && $strFilterByMonth !='all')
{
$strSQL = "SELECT * FROM tblcase where recovered = '".$strFilterByStatus."' and monthreported = '".$strFilterByMonth."'" ;
}
else if($strFilterByStatus != 'all' && $strFilterByYear != 'all' && $strFilterByMonth !='all')
{
$strSQL = "SELECT * FROM tblcase where recovered = '".$strFilterByStatus."' and yearreported = '".$strFilterByYear."' and monthreported = '".$strFilterByMonth."'" ;
}
if (mysql_num_rows($strSQL)==0)
{
$strCaseExist = false;
}
else
{
$SQL=mysql_query($strSQL);
$strCaseExist = true;
}
我有 2 个不同的 SQL 语句,我只想知道它是否会返回一条记录。
最佳答案
您没有执行查询。检查此 manual有关 mysql_num_rows()
的更多详细信息,请像这样更改您的代码
$resrce =mysql_query($strSQL)
if (mysql_num_rows($resrce)==0)
注意 mysql 函数,它们不安全且已弃用。选择mysqli或者pdo
关于php - 修复错误 : mysql_num_rows(): supplied argument is not a valid MySQL result resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22271935/