2013-10-03 4 views
0

내 mysql 데이터베이스의 내용을 검색 할 때 PHP 스크립트에서 따옴표가있는 이상한 문제가 있습니다. Google 크롬에서 다이아몬드 모양의 물음표로 대체되었습니다.데이터베이스의 인용 부호가 다이아몬드의 물음표로 표시됩니다.

내 MySQL 데이터베이스는 데이터 정렬로 설정 : utf8_general_ci 레코드를 아래로 당겨

스크립트의 일부입니다 다음과 같이

<?php 
    echo '<div class="testimonialswrapper">'; 
    // Retrieve Page Content // 
    $testimonialssql = <<<SQL 
     SELECT * 
     FROM `testimonials` 
     ORDER BY id DESC 
     LIMIT 5 
    SQL; 

    if(!$resulttestimonials = $db->query($testimonialssql)){ 
     die('There was an error running the query [' . $db->error . ']'); 
    } 
    while($rowT = $resulttestimonials->fetch_assoc()){ 
     if ($rowT['company'] == ''){$name = $rowT['name'];}else{$name = $rowT['name'].' - '.$rowT['company'];} 
     $from = $rowT['from']; 
     $message = $rowT['message']; 
     echo '<p class="testititle">'.$name.'</p>'; 
     echo '<p class="testifrom">'.$from.'</p>'; 
     echo '<p class="testimessage">'.$message.'</p>'; 
      } 
      echo '</div>'; 
    ?> 

이는 다음을 가지고 내의 index.php에 포함되어 있습니다 설정 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

나는 htmlenteties 및 stripslashes 및 다양한 다른 것들을 사용하여 시도했지만 여전히 동일한 문제가 있습니다.

답변

1

UNICODE REPLACEMENT CHARACTER 가 표시되면 브라우저가 유니 코드 인코딩으로 텍스트를 읽으려고한다는 것을 의미하지만이 값은 실제로 유효한 유니 코드 인코딩으로 인코딩되지 않으므로 undecodable로 바뀌 었습니다.

메타 데이터에서 주장하는대로 데이터베이스의 데이터가 실제로 UTF-8로 인코딩되지 않았습니다. 거기에 라틴 -1로 코드화 된 중괄호가있을 가능성이 높습니다. UTF-8 all the way through my web application (Apache, MySQL, PHP, …)Handling Unicode Front To Back In A Web App을 참조하십시오.

+0

필드 옆에는 utf8_general_ci라고 쓰여 있으며 텍스트는 일반 텍스트 사본이며 기존 웹 사이트에서 phpmyadmin에 붙여 넣습니다. –

+1

링크 된 기사를 읽지 않았습니다. 연결 인코딩이 없습니다! * – deceze

+0

고마워!, mysqli_set_charset ($ db, 'utf8'); –

관련 문제