MySQL 5.0 Reference Manual :: 20 Connectors and APIs :: 20.9 MySQL C API :: 20.9.3 C API Function Descriptions :: 20.9.3.61 mysql_set_character_set()
20.9.3.61. mysql_set_character_set()
int mysql_set_character_set(MYSQL *mysql, const char *csname)
Description
This function is used to set the default character set for the current connection. The string csname specifies a valid character set name. The connection collation becomes the default collation of the character set. This function works like the SET NAMES statement, but also sets the value of mysql->charset, and thus affects the character set used by mysql_real_escape_string()
Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
mysql_real_escape_string
(PHP 4 >= 4.3.0, PHP 5)
mysql_real_escape_string — Escapes special characters in a string for use in a SQL statement
Description
string mysql_real_escape_string ( string $unescaped_string [, resource $link_identifier ] )
Escapes special characters in the unescaped_string , taking into account the current character set of the connection so that it is safe to place it in a mysql_query(). If binary data is to be inserted, this function must be used.
mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.
This function must always (with few exceptions) be used to make data safe before sending a query to MySQL.
mysql_set_charset — Sets the client character set
Description
bool mysql_set_charset ( string $charset [, resource $link_identifier ] )
Sets the default character set for the current connection.
Parameters
charset
A valid character set name.
link_identifier
The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level error is generated.