Is it recommended to use mysql_num_rows() or mysql_result() for checking the existence of a record in PHP?

When checking the existence of a record in PHP, it is recommended to use mysql_num_rows() as it is specifically designed for counting the number of rows returned by a SELECT query. This function returns the number of rows in the result set, which can be used to determine if a record exists or not. On the other hand, mysql_result() is used to fetch a specific field value from a result set, not for checking the existence of records.

// Connect to MySQL database
$conn = mysqli_connect("localhost", "username", "password", "database");

// Query to check if record exists
$query = "SELECT * FROM table_name WHERE condition";
$result = mysqli_query($conn, $query);

// Check if record exists
if(mysqli_num_rows($result) > 0) {
    echo "Record exists";
} else {
    echo "Record does not exist";
}

// Close database connection
mysqli_close($conn);