반응형
    
    
    
  PHP에서는 SLQ Injection을 위해서, mysql_real_escape_string를 많이 사용했다.
그러나, PHP 5.5부터 사용이 규제 되었고, PHP 7.0에서는 사라져 버렸다.
해당 부분을 처리하기 위한 방법
Its pretty simple really:
$db = new PDO($dsn, $user, $password);
$stmt = $db->prepare('INSERT INTO table1 VALUES(?,?)');
$stmt->execute(array($keyword, $guideline));
$stmt->close();
$stmt2 = $db->prepare('SELECT * FROM table2 WHERE keyword= ?');
$stmt->execute(array($keyword));
while(false !== ($row = $stmt->fetch())) {
   // do stuff
}Note that you can also use named placeholders which can help make your code a bit more readable though a bit more verbose:
$stmt2 = $db->prepare('SELECT * FROM table2 WHERE keyword= :keyword');
$stmt2->execute(array(':keyword' => $keyword));반응형
    
    
    
  'WEB언어 > PHP' 카테고리의 다른 글
| PHP 객체지향 방식 (0) | 2017.11.30 | 
|---|---|
| [PHP] HTTP와 HTTPS에 따라 URL변경하기 (0) | 2017.10.26 | 
| [PHP] Notice: Undefined variable 초기값이 없을때 나는 오류 (0) | 2017.10.25 | 
| (따옴표) Single쿼텐션 없애기 / 엔터 없애기 / GET방식 & 와 + 전송하기 (0) | 2017.10.13 | 
| [PHP] addslashes(), stripslashes() 그리고, get_magic_quotes_gpc() (0) | 2017.07.19 | 
| 날짜 포멧 yyyy-dd-mm을 dd/mm/yyyy 변환 (0) | 2017.06.24 | 
| [php] Last Week, This Week, 지난주 다음주 알기, 지난주 일요일 (0) | 2017.06.17 | 
| PHP 5.x 에서 PHP 7으로 업그레이드시 작업 (0) | 2017.06.15 | 
	도움이 되셨다면 하트모양의 "♡ 공감"을 눌러주시면 큰 격려가 됩니다.
(로그인하지 않으셔도 가능)
								
										
	
(로그인하지 않으셔도 가능)