-1

When I request my table that contains japanese symbols set in utf8_unicode_ci, they show instead question marks. How can I make it show the Japanese symbols properly ?

enter image description here

PHP :

<?php

    $query = " SELECT * FROM `kana` WHERE 1 ";

    if ($query_run = mysql_query($query)) {
        while ($query_row = mysql_fetch_assoc($query_run)) {
            $id =  $query_row['id'];
            $hiragana = $query_row['hiragana'];
            $katakana =  $query_row['katakana'];
            $romaji =  $query_row['romaji'];
            $type =  $query_row['type'];
            echo "
                <table class='kana_table'>
                    <tr>
                        <td>
                            $id
                        </td>
                        <td>
                            $hiragana
                        </td>
                        <td>
                            $katakana
                        </td>
                        <td>
                            $romaji
                        </td>
                        <td>
                            $type
                        </td>
                    </tr>
                </table>
            ";
        }
    } else {
        echo mysql_error();
    }
?>
  • Do you have `` in your header? – Muhammad Abdul-Rahim May 01 '15 at 18:39
  • Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard May 01 '15 at 18:45
  • Yes Mari. Thanks for the tip Jay. – Emjy Post-Nothing May 01 '15 at 18:46

2 Answers2

0

I've figured it out from this post : UTF8 and Japanese characters

I had to use this function : mysql_set_charset("utf8");

Community
  • 1
  • 1
0

Please Ensure that....

  1. Database Collation is set as "utf8_unicode_ci".
  2. Set Html Meta charset UTF-8 in HTML tag <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  3. You can also use charset utf8 when query using mysql_query("SET CHARACTER SET utf8 ");

Hope it will help you

tarikul05
  • 1,843
  • 1
  • 16
  • 24