PHPize Online / SQLize Online

Articles    Popular


Tags: PHP 5.x PHP 7.x PHP 8.x

mysqli_real_escape_string — Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection


mysqli_real_escape_string(mysqli $mysql, string $string): string
This function is used to create a legal SQL string that you can use in an SQL statement. The given string is encoded to produce an escaped SQL string, taking into account the current character set of the connection.


A mysqli_result object returned by mysqli_query(), mysqli_store_result(), mysqli_use_result() or mysqli_stmt_get_result().

Procedural style only: A mysqli object returned by mysqli_connect() or mysqli_init()
The string to be escaped. Characters encoded are NUL (ASCII 0), \n, \r, \, ', ", and Control-Z.

Return Values

Returns an escaped string. - New mysqli_real_escape_string snippets