+ Reply to Thread
Results 1 to 6 of 6
Like Tree2Likes
  • 1 Post By bissatch70
  • 1 Post By nakama

Thread: Problem displaying Japanese charset (UTF-8) in PHP

  1. #1
    bissatch70 is offline x10Hosting Member bissatch70 is an unknown quantity at this point
    Join Date
    Jan 2011
    Posts
    1

    Problem displaying Japanese charset (UTF-8) in PHP

    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
    dinomirt96 likes this.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Problem displaying Japanese charset (UTF-8) in PHP

    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.
    Nothing is always absolutely so.

  3. #3
    nakama is offline x10Hosting Member nakama is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    8

    Re: Problem displaying Japanese charset (UTF-8) in PHP

    I have the same problem.
    karimirt47 likes this.

  4. #4
    fomalhaut is offline x10Hosting Member fomalhaut is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    South of France near Arles
    Posts
    91

    Re: Problem displaying Japanese charset (UTF-8) in PHP

    Hello

    Have you insert this meta tag in your html script ?

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

  5. #5
    tcp_udp12 is offline x10Hosting Member tcp_udp12 is an unknown quantity at this point
    Join Date
    Sep 2011
    Posts
    1

    Re: Problem displaying Japanese charset (UTF-8) in PHP

    At first, you must set character set in database connection before any SELECT, UPDATE or INSERT query
    PHP Code:
    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 Code:
    <?php
    header
    ('content-type: text/html; charset=utf-8');
    ?>
    or
    HTML Code:
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

  6. #6
    John Rambo is offline x10Hosting Member John Rambo is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    21

    Re: Problem displaying Japanese charset (UTF-8) in PHP

    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.

+ Reply to Thread

Similar Threads

  1. AJAX charset trouble
    By LordAlucard in forum Programming Help
    Replies: 4
    Last Post: 06-14-2008, 12:18 AM
  2. Replies: 11
    Last Post: 01-04-2008, 04:34 PM
  3. Any Japanese learners?
    By drfr4g in forum Off Topic
    Replies: 4
    Last Post: 09-10-2007, 05:51 PM
  4. Charset problem
    By jettadelv in forum Free Hosting
    Replies: 20
    Last Post: 08-30-2007, 02:14 PM
  5. Prettiest Japanese Singer / Group
    By motogawa in forum Off Topic
    Replies: 10
    Last Post: 10-25-2005, 08:29 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers