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

search for in the

mysql_fetch_array> <mysql_error
[edit] Last updated: Fri, 23 Mar 2012

view this page in

mysql_escape_string

(PHP 4 >= 4.0.3, PHP 5)

mysql_escape_string Dodaje znaki unikowe na użytek mysql_query

Opis

string mysql_escape_string ( string $łańcuch_bez_znaków_unikowych )

Ta funkcja wstawi znaki unikowe do łańcuch_bez_znaków_unikowych, aby bezpiecznym było umieszczenie go w mysql_query().

Informacja: mysql_escape_string() nie dotyczy znaków % i _. Funkcja ta działa identycznie jak mysql_real_escape_string(), z tym wyjątkiem, że mysql_real_escape_string() pobiera identyfikator połączenia i wstawia znaki unikowe zgodnie z bieżącym zestawem znaków. mysql_escape_string() nie pobiera identyfikatora połączenia i nie bierze pod uwagę bieżącego zestawu znaków.

Przykład #1 przykład użycia mysql_escape_string()

<?php
$item 
"Zak's Laptop";
$escaped_item mysql_escape_string($item); 
printf ("Łańcuch ze znakami unikowymi: %s\n"$escaped_item);
?>

Powyższy przykład da następujący wynik:

Łańcuch ze znakami unikowymi: Zak\'s Laptop

Patrz także: mysql_real_escape_string(), addslashes() oraz dyrektywa magic_quotes_gpc.



add a note add a note User Contributed Notes mysql_escape_string
s dot marechal at jejik dot com 26-Jan-2011 02:37
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).
as_lh 26-Mar-2010 05:05
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