2016-10-06 14 views
-1

私はこのPHPコードを持っていますが、私の問題はutf8のcharsetです。 mysqlからデータを取得するとき、utf8は機能しません。何が間違っているかについてのアイデア? MySQL照合はutf8_general_ciです。しかし、私のPHPはまだギリシャの代わりに私に多くの疑問符(?)を表示します。以下は、私の検索結果、私のsqlserverと私のデータベースの3つのスクリーンショットがあります。どんな助けも素晴らしいだろう。ありがとう。すべてのMySQLのエンコーディングPHP Utf8の失敗

mysqli_query($connect, "SET NAMES 'utf8'"); 

チェックPHP内部文字エンコーディング

echo mb_internal_encoding(); 

設定し

http://prntscr.com/cqj1ei http://prntscr.com/cqj25d

<?php 

if(isset($_POST['search'])) 
{ 
    $valueToSearch = $_POST['valueToSearch']; 
    $sql = "SELECT * FROM `works` WHERE CONCAT(`Onomateponumo`, `Odos`, `Arithmos`, `Perioxi`, `Hmerominia`, `Ora`, `Ergasia`, `Amoivi`, `Ypallilos`, `Tilefono`, `Alles_plirofories`) LIKE '%".$valueToSearch."%'"; 
    $search_result = filterTable($sql); 
} 
else { 
    $sql = "SELECT * FROM `works`"; 
    $search_result = filterTable($sql); 
} 

function filterTable($sql) 
{ 
    $connect = mysqli_connect("localhost", "root", "", "works1"); 
    $filter_Result = mysqli_query($connect, $sql); 
    mysqli_set_charset($connect, "utf8"); 
    return $filter_Result; 
} 

?> 
<?php header('Content-Type: text/html; charset=utf-8');?> 
<!DOCTYPE html> 
<html> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
     <title>Προγραμμα Αναζητησης</title> 
     <style> 
      table,tr,th,td 
      { 
       border: 1px solid black; 
      } 
     </style> 
    </head> 
    <body> 

     <form action="fetch.php" method="post"> 
      <input type="text" name="valueToSearch" placeholder="Value To Search"><br><br> 
      <input type="submit" name="search" value="Filter"><br><br> 

      <table> 
       <tr> 
        <th>Όνοματεπώνυμο</th> 
        <th>Διεύθυνση</th> 
        <th>Τηλέφωνο</th> 
        <th>Περιοχή</th> 
        <th>Ημερομηνία</th> 
        <th>Εργασία</th> 
        <th>Αμοιβή</th> 
        <th>Υπάλληλος</th> 
        <th>Τηλέφωνο</th> 
        <th>Πληροφορίες</th> 
       </tr> 
       <?php while($row = mysqli_fetch_array($search_result)):?> 
       <tr> 
        <td><?php echo $row['Onomateponumo'];?></td> 
        <td><?php echo $row['Odos'];?></td> 
        <td><?php echo $row['Arithmos'];?></td> 
        <td><?php echo $row['Perioxi'];?></td> 
        <td><?php echo $row['Hmerominia'];?></td> 
        <td><?php echo $row['Ergasia'];?></td> 
        <td><?php echo $row['Amoivi'];?></td> 
        <td><?php echo $row['Ypallilos'];?></td> 
        <td><?php echo $row['Tilefono'];?></td> 
        <td><?php echo $row['Alles_plirofories'];?></td> 
       </tr> 

       <?php endwhile;?> 
      </table> 


     </form> 


    </body> 
</html> 
+0

てみ '​​<?phpのエコーutf8_decode($行[ 'Onomateponumo']);?>自体がテーブルの上に'など。 –

+0

...と照合?さらに良い方法は次のとおりです:http://stackoverflow.com/questions/279170/utf-8-all-the-way-through/279279 – CD001

+0

データベースについてはどうですか? DBのデータは正常ですか?またはで利用できる??? – devpro

答えて

0

ていない場合はUTF-8

mb_internal_encoding("UTF-8"); 
+0

UTF8を返しますが、結果はまだありません。 http://prntscr.com/cqjiew –

+0

@ChristosKyritsis:あなたは試しましたか? ($ row ['Onomateponumo']、ENT_QUOTES、 'UTF-8') – devpro

+0

'mysqli_set_charset($ connect、" utf8 ");'はクエリが役に立たない後です。クエリの前に 'mysqli_query($ connect、" SET NAMES 'utf8' ");'を設定します。 – MichaEL