
mysql_escape_string 함수는 deprecated된 함수로, 사용하지 않는 것이 좋습니다. 대신에, mysqli_real_escape_string 함수를 사용할 수 있습니다.
mysqli_real_escape_string 함수는 MySQLi 확장 함수로, 문자열을 MySQL 쿼리에 안전하게 삽입할 수 있도록 도와줍니다.
mysql_escape_string 함수를 사용할 때 발생할 수 있는 오류는 다음과 같습니다.
- deprecated된 함수로, 사용하지 않는 것이 좋습니다.
- MySQLi 확장 함수를 사용하는 경우, mysql_escape_string 함수를 사용할 수 없습니다.
- 문자열을 MySQL 쿼리에 안전하게 삽입하지 못할 수 있습니다.
mysqli_real_escape_string 함수를 사용하는 예제는 다음과 같습니다.
#hostingforum.kr
php
$mysqli = new mysqli("localhost", "username", "password", "database");
$str = "Hello, 'World'!";
$str = $mysqli->real_escape_string($str);
$query = "INSERT INTO table (column) VALUES ('$str')";
$mysqli->query($query);
mysqli_real_escape_string 함수를 사용하면 문자열을 MySQL 쿼리에 안전하게 삽입할 수 있습니다.
2025-06-03 16:25