Problem displaying Japanese charset (UTF-8) in PHP

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by bissatch70, Mar 3, 2011.

  1. bissatch70

    bissatch70 New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I want to store English and Japanese in a database table which I have managed to achieve by setting the database to UTF-8 (supports both). When I check the table in phpmyadmin the Japanese is there. However, when I extract the Japanese data using a PHP script and display it in the browser it comes out as ???????????????????? - is this because the apache/php server is not set as UTF-8? I have been able to set this in my apache.conf file on my local server on my PC but I doubt I'll have such control from a hosting server which I understand. Is there any method to allow me to display these characters? Can this be set from the x10 cpanel? Or even the PHP script?

    Cheers
    Bizt
     
  2. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    I've seen plenty of blogs, forums, etc hosted here in non-Western character sets. They all use the same Apache + PHP+MySQL you do.
     
  3. nakama

    nakama New Member

    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    I have the same problem.
     
  4. fomalhaut

    fomalhaut Member

    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    6
    Hello

    Have you insert this meta tag in your html script ?

    HTML:
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
     
  5. tcp_udp12

    tcp_udp12 New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    At first, you must set character set in database connection before any SELECT, UPDATE or INSERT query
    PHP:
    mysql_query'SET NAMES utf8' );
    then, your site must send data in UTF-8:
    encoding of the source files must be UTF-8
    and site must send header which inform browser to display your site in UTF-8
    PHP:
    <?php
    header
    ('content-type: text/html; charset=utf-8');
    ?>
    or
    HTML:
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
     
  6. John Rambo

    John Rambo New Member

    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    It's a database problem.
    Generally one should choose proper charset/collation (utf8/utf8_general_ci) for databases/tables.
    If a table has wrong charset/collation you will get questions (????)when you want to write something in it.

    In your case it seems you have right charset/collation for tables, as when you see data in pma it's ok. So you should use query, mentioned above to set charset, every time before other queries.
     

Share This Page