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

mysql_escape_string(string $stringa_senza_escape): string

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 2 notes

up
8
PHPguru
8 years ago
You can use this function safely with your MySQL database queries if and only if you are sure that your database connection is using ASCII, UTF-8, or ISO-8859-* and that the backslash is your database's escape character. If you're not sure, then use mysqli_real_escape_string instead. This function is not safe to use on databases with multi-byte character sets.

The only benefit of this function is that it does not require a database connection.
up
-28
s dot marechal at jejik dot com
12 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).
To Top