How can the error "Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in" be resolved in PHP?

The error "Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in" occurs when the query execution fails and returns a boolean value instead of a resource. To resolve this issue, you should check if the query was executed successfully before fetching the results.

$result = mysql_query($query);

if($result) {
    while($row = mysql_fetch_row($result)) {
        // Process the fetched row data
    }
} else {
    echo "Query execution failed";
}