의견 상자 양식이 실행 중이며 '
을 사용하면 앞에 \
이 생성됩니다. 예를 들어, "how 's"라고 쓰면, 데이터베이스에 게시하는 방법과 페이지에 표시 할 때 "how \ 's"로 표시됩니다. "body"텍스트를 표시 할 때 stripslashes
함수를 사용하고 있습니다.이 텍스트는 슬래시를 제거하기로되어 있다고 생각했습니다.스트립 슬래시 사용에도 불구하고 표시된 양식 텍스트에 슬래시가 표시됩니다.
제 서버가 PHP 5.3.6을 실행 중입니다. 내 데이터베이스에 메모 상자의 몸에서 텍스트를 작성하려면이 코드 조각을 사용하고
:
function mysql_prep($string) {
global $connection;
$escaped_string = mysqli_real_escape_string($connection, $string);
return $escaped_string;
}
사이드 :
$body = mysql_prep($_POST['body']);
가 사용하는 기능이있다 참고 :이 질문에 대답 할 필요는 없지만, 텍스트 사용자가 해커, baddies 등으로부터 안전하게 입력하도록하기 위해 사용하고있는 기능입니다. 나는 그 일을 잘하고 있습니까, 아니면 제가 스스로 이슈에 개방적으로 남겨두고 있습니까?
이 내가 텍스트를 표시하는 데 사용하고 코드입니다 (때문에이 기능이 될 수있는이 슬래시 문제 외에) : 감사,
<div id="comments">
<?php while($comment_text = mysqli_fetch_assoc($display_comments)) { ?>
<div class="comment" style="margin-bottom: 2em;">
<div class="author">
<b><?php echo htmlentities($comment_text["author"]); ?>:</b>
</div>
<div class="meta-info" style="font-size: 0.8em;">
<?php echo datetime_to_text($comment_text["created"]); ?>
</div>
<div class="body">
<?php echo stripslashes($comment_text["body"], '<strong><em><p>'); ?>
</div>
</div>
<?php } ?>
<?php if(empty($display_comments)) { echo "No Comments."; } ?>
</div>
어떤 도움이나 조언은 매우 감사합니다!
'stripslashes()'이 보이지 않습니다. 나는'strip_tags()'만 보았습니다 (다른 것을합니다). –
MySQLi 쿼리를 준비 할 때'mysqli_real_escape_string()'함수가 필요 없다. –
oh dang, ur right @Gerald Schneider! 나는 그걸 꺼내서 스트립 슬래시를 대신 넣을거야? 내가 그 일을 함으로 뭔가를 망쳐 놓지 않는 한 ... – coolpup