mysql_real_escape_string — Escapes special characters in a string

unsigned long mysql_real_escape_string(MYSQL * mysql,
                                       char * to,
                                       const char * from,
                                       unsigned long);

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

Parameters

mysql

A mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

to

buffer for the encoded string. The size of this buffer must be length * 2 + 1 bytes: in worst case every character of the from stirng needs to be escaped. Additionally a trailing 0 character will be appended.

from

An string which will be encoded by mysql_real_escape_string().

long

The length of from string.

Return value

Returns the length of the encoded (to) string.

[Note]

todo!

See also