downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

mysql_fetch_array> <mysql_error
[edit] Last updated: Fri, 17 May 2013

view this page in

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

string mysql_escape_string ( string $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 .



add a note add a note User Contributed Notes mysql_escape_string - [2 notes]
up
-1
s dot marechal at jejik dot com
2 years ago
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).
up
-1
as_lh
3 years ago
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.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites