What are some alternative methods or best practices to avoid errors like "Unable to jump to row" when using mysql_result in PHP?

When using mysql_result in PHP, the error "Unable to jump to row" can occur when trying to access a row that does not exist in the result set. To avoid this error, you can check if the row exists before trying to access it. One way to do this is by using the mysql_num_rows function to determine the number of rows in the result set and then checking if the desired row index is within that range.

$result = mysql_query("SELECT * FROM table");
if(mysql_num_rows($result) > 0){
    $row = mysql_result($result, $row_index, $column_name);
    // do something with the row data
} else {
    // handle the case where no rows are returned
}