How can the issue of passing a null parameter to mysqli_real_escape_string() be resolved in PHP?

When passing a null parameter to mysqli_real_escape_string() in PHP, it can cause a warning or error to be thrown because the function expects a string parameter. To resolve this issue, you can check if the parameter is null before calling the function and handle it accordingly, such as by setting an empty string as the input.

// Check if the parameter is null and handle it appropriately
if ($input == null) {
    $escaped_input = '';
} else {
    $escaped_input = mysqli_real_escape_string($connection, $input);
}