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: Sat, 07 Jan 2012

view this page in

mysql_escape_string

(PHP 4 >= 4.0.3, PHP 5)

mysql_escape_stringmysql_query에서 문자열을 escape하기위해 사용

설명

string mysql_escape_string ( string $unescaped_string )

이 함수는 unescaped_stringmysql_query()에 안전하도록 escape시킨다. 이 함수의 사용은 권장하지 않는다.

이 함수는 접속 핸들러를 이용하여 현재 문자셋을 따라서 문자를 escape하는 것만 제외하고는 mysql_real_escape_string()와 비슷하다. mysql_escape_string()는 접속 핸들러를 인수로 갖지 않으며, 현재 문자셋에 대해 고려하지 않는다.

인수

unescaped_string

Escape할 문자열.

반환값

Escape된 문자열.

변경점

버전 설명
5.3.0 E_DEPRECATED 주의가 발생합니다.
4.3.0 이 함수의 사용은 권장하지 않는다. 대신, mysql_real_escape_string()를 사용하라.

예제

Example #1 mysql_escape_string() 예제

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

위 예제의 출력:

Escaped string: Zak\'s Laptop

주의

Note:

mysql_escape_string()%_를 escape하지 않는다.

참고



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