it seems the function changes the character encoding of the string.
I get utf-8 encoded string and my mysql database is set to utf-8 as well.
If i just write the data to the database it works perfectly fine, if i use this function, it changes the encoding and therefore stores the wrong characters.
Seems like a bug to me.
mysql_escape_string
(PHP 4 >= 4.0.3, PHP 5)
mysql_escape_string — Aggiunge le sequenze di escape in una stringa per l'uso in mysql_query.
Descrizione
$stringa_senza_escape
)
Questa funzione aggiunge le sequenze di escape a stringa_senza_escape,
in modo che sia sicuro usarla in mysql_query().
Nota: mysql_escape_string() non aggiunge le sequenze di escape a % ed a _. Questa funzione รจ identica a mysql_real_escape_string() eccetto che mysql_real_escape_string() accetta un identificativo di connessione ed aggiunge le sequenze di escape alla stringa in base al set di caratteri corrente. mysql_escape_string() non accetta come argomento un identificativo di connessione e non rispetta le impostazioni del corrente set di caratteri.
Example #1 Esempio di mysql_escape_string()
<?php
$voce = "Zak's Laptop";
$voce_con_escape = mysql_escape_string($voce);
printf ("La stringa con le sequenze di escape: %s\n", $voce_con_escape);
?>
L'esempio riportato sopra dovrebbe produrre il seguente output:
La stringa con le sequenze di escape: Zak\'s Laptop
Vedere anche: mysql_real_escape_string(), addslashes(), e la direttiva magic_quotes_gpc .
The exact characters that are escaped by this function are the null byte (0), newline (\n), carriage return (\r), backslash (\), single quote ('), double quote (") and substiture (SUB, or \032).
