Are there alternative functions in PHP, such as mysql_escape_string, that can be used for escaping without considering encoding?

When it comes to escaping user input in PHP, it's important to consider both escaping special characters and encoding the data properly to prevent SQL injection attacks. While functions like `mysql_escape_string` used to be commonly used for escaping in older versions of PHP, it is now deprecated and not recommended for use. Instead, you should use parameterized queries with prepared statements or the `mysqli_real_escape_string` function to properly escape user input without worrying about encoding.

// Using mysqli_real_escape_string to escape user input
$mysqli = new mysqli("localhost", "username", "password", "database");

// Check connection
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Escape user input
$user_input = "some user input";
$escaped_input = $mysqli->real_escape_string($user_input);

// Use the escaped input in your query
$query = "SELECT * FROM table WHERE column = '$escaped_input'";
$result = $mysqli->query($query);

// Remember to properly handle the query result