2016-09-29 4 views
0
I가 내 파일이, 캐릭터 등 UTF8을 사용 UTF8 내 데이터베이스를 설정했지만 TinyMCE를 행 내 삽입이

HTML 엔티티 (& LT; P &한다 Jabbathehut & LT/P &있다 ; rn & a ...) b, strong, p 등 인쇄하려고합니다. 나는 몇 가지 솔루션을 시도 https://i.gyazo.com/bfc1c3a7ba7d22ae4673202939ab0046.png : 등 htmlspecialchars($htmlsanitize, ENT_QUOTES, 'UTF-8');TinyMCE에 출력

$getProgress = mysql_query("SELECT * FROM cms_comments WHERE article = $number AND userid = '".$_SESSION['user']['id']."'"); 
while($progressinfo = mysql_fetch_array($getProgress)) 
{   
    echo '<h4><b>Din besvarelse</b></h4> 
'.htmlspecialchars_decode($progressinfo['comment']).''; 

어떤 제안하지만 난은이 같은 일반 텍스트를 얻을?

+0

데이터가 DB, 그것은 개체 또는 태그를 포함 않습니다 당신은 문자를 의미 raw하는 XML 기본 개체를 제외하고 비 엔터티 형식으로 저장됩니다에 entity_encoding 설정할 수 있습니까? – atoms

+0

@atoms 삽입 이미지 : https://i.gyazo.com/3cf236571a5dd296746fc4d16c4d4918.png –

+0

html_entity_decode()를 사용하여보십시오. –

답변

0

삽입을 수행하는 더 좋은 방법은 PDO를 사용하는 것이고, 선택 문에 대해 동일한 작업을 수행해야합니다.

이 방법을 사용하면 변환 된 엔터티를 DB에 삽입하는 것과 관련된 모든 문제를 해결할 수 있다고 생각합니다.

// define allowed tags 
define('ALLOWED_TAGS', '<p>,<strong>,<ul>,<li>,<ol>,<em><br>'); 

$sContent = ''; 

// if form has been posted 
if(isset($_POST['Create'])){ 

    // Read content from WYSIWYG 
    if(isset($_POST['Article']) && $_POST['Article'] != ''){ 

     if(strlen(strip_tags($_POST['Article'], ALLOWED_TAGS)) > 10){ 

      $sArticle = strip_tags($_POST['Article'], ALLOWED_TAGS); 

     }else $sError .= "[ArticleLength]"; 

    } 
    if($sArticle == "") $sError .= "[Article]"; 


    // nothing in error string. proceed to insert 
    if($sError == ''){ 

     // create an instance of the connection 
     $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); 

     // prepare the sql 
     $sSQL = "INSERT INTO cms_comments (Article, col2) VALUES (:Article, :col2)"; 
     $st = $conn->prepare($sSQL); 

     // bind the input vars 
     $st->bindValue(":Article", $sArticle, PDO::PARAM_STR); 
     $st->bindValue(":col2", $col2, PDO::PARAM_STR); 
     $st->execute(); 

    } 

}