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: Wed, 19 Jun 2013

view this page in

mysql_escape_string

(PHP 4 >= 4.0.3, PHP 5)

mysql_escape_stringEscapeaza un string pentru fi folosit in mysql_query

Descrierea

string mysql_escape_string ( string $unescaped_string )

Aceasta functie va escapa variabila unescaped_string, asa incat sa poata fi folosita in functia mysql_query() intr-un mod securizat. Aceasta functie este va fi scoasa din uz.

Aceasta functie este identica cu mysql_real_escape_string() cu exceptia ca mysql_real_escape_string() se foloseste de conexiunea curenta si escapeaza string-ul in fuctie de encodingul (charset-ul) setat. mysql_escape_string() nu ia ca argument conexiunea curenta si nu respecta encodingul setat la momentul respectiv.

Avertizare

Această funcție a fost DEZAPROBATĂ începând cu PHP 5.3.0. Utilizarea acestei facilități este foarte nerecomandată.

Parametri

unescaped_string

String-ul ce urmeaza sa fie escapat.

Valorile întoarse

Returneaza string-ul escapat.

Istoria schimbărilor

Versiunea Descriere
5.3.0 Aceasta functie returneaza o notificare de tip E_DEPRECATED.
4.3.0 Aceasta functie este scoasa din uz, nu o mai folositi. In locul ei, folositi mysql_real_escape_string().

Exemple

Example #1 exemplu de uz al functiei mysql_escape_string()

<?php
$item 
"Zak's Laptop";
$escaped_item mysql_escape_string($item);
printf("Escaped string: %s\n"$escaped_item);
?>

Exemplul de mai sus va afișa:

Escaped string: Zak\'s Laptop

Note

Notă:

mysql_escape_string() nu escapeaza caracterele % si _.

Vedeți de asemenea



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 | sitemap | contact | advertising | mirror sites