I'm trying to check if an sql query brings back any results in PHP, I've tried using mysql_num_rows($res) but I keep getting an error saying that the function expected parameter to be a resource but it is instead getting an object.
I've attached the relevant code here
$dsn = "mysql://$username:$password@$host/$dbName"; 
require_once('MDB2.php');    
$db =& MDB2::connect($dsn);
if(PEAR::isError($db)){ 
    die($db->getMessage());
}
$sql=//sql query
$res =& $db->query($sql);
if(PEAR::isError($res)){
    die($res->getMessage());
}
$resultsFound = false; 
if (mysql_num_rows($res)>0){
while($row=$res->fetchRow()){
    //insert results here
}
} else {
     echo "<br><h2>Sorry, invalid input</h2>";
}
I'm sure the solution is fiendlishly simple but I'm new to php and sql and would really appreciate your help!
 
    