2013-05-04 8 views
0

DB에 입력을 저장하는 데 문제가 있습니다.읽기 슬래시에서 충돌이 발생합니다.

나는 나의 DB 내 문자열을 저장합니다

mysql_real_escape_string($my_string) 

그런 다음, 나는 읽기와 나는이를 사용하여 입력 문자열을 배치 : 나는 두 번 설정하면

stripslashes($my_string) 

점이며, 내 문자열에 슬래시를 넣으면 입력이 다음과 같이 충돌합니다.

<input maxlength = "150" type="text" name = "my_string12" value = "hello "this is" a test" class="input-medium"/> 

감사합니다.

+0

변화처럼 입력 작업을해야 – matzone

+0

'이다'. 하지만 내 사용자에게 이중 따옴표 대신 작은 따옴표를 사용한다고 말할 수는 없습니다 ... –

답변

0

PHP 변수로 값이 다음을 손질해야하는 경우 ..

사용하여 트림 기능 :

$str = 'hello "this is" a test'; 
echo trim($str, '"'); // hello this is a test 

here

0

에서 폴 응답 당신은

을 사용할 수 있습니다 <?php echo addslashes('hello "this is" a test'); // hello \"this is\" a test ?>

줄무늬 그것을

<?php echo stripslashes('hello \"this is\" a test'); // hello "this is" a test ?>

를 제거하거나이

value = 'hello "this is" a test' 또는 value = "hello 'this is' a test"

관련 문제