What are common issues when using mysql_num_rows in PHP scripts?

Common issues when using mysql_num_rows in PHP scripts include not properly checking if the query was successful before calling mysql_num_rows, and not freeing the result set after using it. To solve these issues, always check if the query was successful before calling mysql_num_rows, and free the result set after using it to release memory.

// Check if the query was successful before calling mysql_num_rows
$result = mysql_query($query);
if($result){
    $num_rows = mysql_num_rows($result);
    // Process the result
    mysql_free_result($result); // Free the result set
} else {
    echo "Error executing query: " . mysql_error();
}