html 을 MySql 에 넣었다 뺏더니 코드가 그대로 나옴
본문
html 을 MySql 에 넣었다 뺏더니 코드가 그대로 나옴
다시 html button 코드가 작동하게 하려면 어떻게 해야 하나요?
답변 4
mysql 에 html 등록되면서 혹시 특수문자코드로 치환되면서 그런게 아닌가 싶은데
소스에 > %lt; 부분이 변환이 되지 않았는지 확인해 보세요
다음과 같은 방법도 있으니 참고해 보세요
// 데이터베이스에서 HTML 코드 가져오기
$sql = "SELECT html_code FROM your_table WHERE your_condition";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo $row["html_code"];
}
} else {
echo "No results found";
}
db 단에서 코드가 제대로 들어가있는지 채크부터 해보세요.
https://www.php.net/manual/en/function.htmlspecialchars-decode.php
https://www.php.net/manual/en/function.html-entity-decode.php
답변을 작성하시기 전에 로그인 해주세요.