chinese characters

Discussion in 'PHP' started by klown, Jul 21, 2006.

  1. #1
    seems that i cant get chinese characterse from mysql and echo them successfully.

    I have tried setting encodings to gb2312 and utf8, both dont work.

    		
    $query = "SELECT * FROM chinese WHERE uid='111111'";		
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result);		
    echo $row['word'];
    
    PHP:
    this displays ????????'s

    been researching all afternoon for the answer. My page encoding is correct, and im displaying chinese characters echo'd normally.

    echo "<br><br>筛选:把葡萄的果实和葡萄梗分开";
    PHP:
     
    klown, Jul 21, 2006 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Change your Web Browser Language Character set from English to Chinese.... I believe your browser is seeing the correct characters, but doesn't know to render them using Chinese characters.
     
    ccoonen, Jul 22, 2006 IP
  3. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #3
    no its not, i can see characters fine, however the page doesnt get the correct characters from mysql. As above i did an echo with characters and that displays, however the echo from mysql data displays only ???s
     
    klown, Jul 22, 2006 IP
  4. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just a thought, does the collation method in the database make a difference? i.e. is it possible to check that it is actually storing double byte data?
     
    rosytoes, Jul 23, 2006 IP
  5. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    what version of mysql are u running?

    heres few things u need, set the collumn in the table to "utf-8, general ci"

    set the ur meta tag to "utf-8"

    if u gonna work in unicode string make sure php is compiled (on linux) or has (on windows) the mbstring extension




    im after completeing my latest CMS that runs on php5, mysql5, apache 2

    with complete unicode support, came across all these problems,

    unfortunately php is shite when it comes to unicode (compared to java or c# or nay other decent language), the word on the street is that php6 will have unicode support, but thats years away from popular adoption heck php5 was out for years and no one is using it really
     
    wwm, Jul 23, 2006 IP
  6. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #6
    MySQL version 4.1.14-standard
    PHP version 4.4.2
    is this the problem? It is running on an Apache version 1.3.34 (Unix)
    perhaps this needs to be updated?

    I've tried with many different sets of encodings, none work. UTF-8 would be ideal since im storing english, french, and chinese in this database. I've heard that about php6 too when i was researching how to use chinese chars. Anyhow i'm using PHP (already have the scripts done to handle the english and french version, just need to finish the chinese part).

    Basically my encodings are correct i'll talk to the server administrators to see if they can update things.
     
    klown, Jul 23, 2006 IP
  7. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    im not sure if mysql4 fully supports utf-8, u better look into it

    im using mysql5 on my server, and an excellent program called navicat to manage,create,backup remotely the database (becase phpmyadmin is slow and i had trouble with unicode and that program)


    i recommend googling for wampserver i use it to develop on my laptop, itll install mysql5, php5 and 4,apache2 and itll let u easily switch between php4 and php5 on ur localhost
     
    wwm, Jul 23, 2006 IP
  8. klown

    klown Peon

    Messages:
    2,093
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Actually im using a hosting service, so i'm using their mysql and php.
     
    klown, Jul 23, 2006 IP
  9. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    wwm, Jul 28, 2006 IP
  10. wwm

    wwm Peon

    Messages:
    308
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #10
    oh i think theres a trick u can do if database doesnt support unicode, use htmlentities this will encode all weird characters ;) but u will loose things like unicode searching...


    this is a very grey area for php mysql unfortunately
     
    wwm, Jul 28, 2006 IP