PHP : mysql_real_escape_string()

munilive
munilive

mysql_real_escape_string() PHP에서 SQL Injection 공격 등을 방어하기 위하여 특수 문자열을 이스케이프 하기 위한 함수이다.
mysql_real_escape_string() 함수를 호출하면 \x00, \n, \r, \, ', ", \x1a와 같은 문자 앞에 \(역슬레시)를 붙여서 해당 문자가 실제 작동하지 않도록 이스케이프 해준다.
이 함수는 쿼리를 MySQL로 보내기 전에 항상 테이터를 안전하게 만드는 데 사용 되어야 한다.

PHP 매뉴얼 참고: https://www.php.net/manual/en/function.mysql-real-escape-string

PHP 5.5.5버전부터 해당 함수는 deprecated 되었다.
PHP 7.0.0버전부터는 삭제되어 더는 사용할 수 없다.
대체 함수로 mysqli_real_escape_string(), PDO::quote()가 있다.

munilive

munilive

Backend Application Developer

Share

Comments

Related Posts

`strtotime`에선 `-1 months` 또는 `1 month ago`는 30일 이전이 아니다.

`strtotime`에선 `-1 months` 또는 `1 month ago`는 30일 이전이 아니다.

PHP에서 함수를 참으로 많이 사용한다. 날짜를 계산 할 때 이보다 편한 건 없기 때문이라고 할까나. 그런데 오늘 중요한 사실을 알았다. 머 이전부터 매뉴얼에는 나와 있었지만…

munilive munilive ·
PHP Geo IP Location : 확장설치

PHP Geo IP Location : 확장설치

PHP에서 Geo IP Location 관련 함수를 사용하기 위해서는 Geo IP Location 모듈을 확장 설치 해야 한다. Geo IP 함수를 이용하면, 아이피 주소를 통하여…

munilive munilive ·
Image Mime Type for PHP

Image Mime Type for PHP

PHP에서 사용되는 Image Type에 대한 매직넘버와 타입명 입니다. 공통으로 사용되는 Mine Type과 매핑하여 테이블로 정리 하였습니다. {:caption="PHP Ima…

munilive munilive ·