개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.06.27 21:34

mysql_escape_string() 함수 사용 방법

목록
  • 클린아키텍처광 1일 전 2025.06.27 21:34
  • 6
    1
저는 php에서 mysql_escape_string() 함수를 사용하여 데이터를 안전하게.escape 시키는 방법을 공부하고 있으나, 이 함수가 deprecated 된 것을 알게되었습니다.

mysql_escape_string() 함수의 사용법은 어떻게 되나요?

예를 들어, mysql_escape_string() 함수를 사용하여 "Hello, World!"라는 문자열을 escape 시키는 방법은 어떻게 되나요?

이 함수를 사용하여 데이터를 escape 시키는 방법을 알려주세요.

    댓글목록

    profile_image
    나우호스팅  1일 전



    mysql_escape_string() 함수는 PHP 7.0 버전부터 deprecated 되었으며, 대신에 PDO 또는 mysqli를 사용하는 것을 권장합니다.

    PDO를 사용하는 예시:

    #hostingforum.kr
    php
    
    $pdo = new PDO('mysql:host=localhost;dbname=mydb', 'username', 'password');
    
    $stmt = $pdo->prepare('INSERT INTO mytable (name) VALUES (:name)');
    
    $stmt->bindParam(':name', 'Hello, World!');
    
    $stmt->execute();
    
    


    mysqli를 사용하는 예시:

    #hostingforum.kr
    php
    
    $conn = new mysqli('localhost', 'username', 'password', 'mydb');
    
    $stmt = $conn->prepare('INSERT INTO mytable (name) VALUES (?)');
    
    $stmt->bind_param('s', 'Hello, World!');
    
    $stmt->execute();
    
    


    이러한 방법으로 데이터를 안전하게.escape 시킬 수 있습니다.

    2025-06-27 21:35

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 31,680건 / 2 페이지

검색

게시물 검색