Thailanguage with php mysql

Posted on 2004-10-30
Last Modified: 2006-11-17
when I read the data from my sql in Thai language it show like this ทดสอบภาไทย
How can i solve this problem
Question by:teera
    LVL 12

    Expert Comment


    Try this:
    Set your web page charset encode to charset=utf-8 (unicode) like this:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta http-equiv="Content-Type" content="text/html; charset=tis-620">

    LVL 48

    Expert Comment

    Could you give more infromation, which mysql-server are you using, which php-version and which phpgroupware-version.
    Is the correct code-page generated by phpgroupware for that page. Is your browser capable of displaying those characters?

    Have you opend a bug-report at:
    LVL 49

    Expert Comment

    Well, in some way it seems that you execute some htmlspecialchars or htmlentities on the original string.

    This could be pre-db-insertion or post-db-select, e.g. done before you submit data into the database, or after reading from the database.

    It would be most welcome if you where able to check what's inside the actual database (using phpmyadmin or another tool.)
    If the thai is htmlentities'd before inserting into the database this requires a whole other solution then when it is not.



    Author Comment

    I check on thai word that I type when it go to mysql database it change to  
    LVL 12

    Expert Comment

    I think it is like that in the Database is because, the DB need to store Raw data and not encoded data.
    Even if it stores the Thai characters like #3607;&#3604;&#3626;&#3629;&#3610;&#3616;&#3634;&#3652;&#3607;&#3618 when you extract them from the database and display them on the web page it should display the proper thai characters.
    LVL 29

    Accepted Solution

    You need to be sure that all the whole chain is utf8.
    That is:
    1 - your php page being itself utf_8 encoded;
    2 - this php page generates an html header described by minichicken in the FIRST lines of your html code
    3 - when getting data from a db, you do the proper encoding to output text in utf-8
    4 - when looking at the page with your browser this is using the code you have selected in the steps above.

    Point 4: if you are using IE, "Dsplay" / "Code"  [Sorry, not sure this is the exact wording in English] and the check which code is currently active. Try to change it for UTF-8: is your page looking better?
    Also look at the page source code: where is the line with "charset"? is it in the first lines?

    Point 3: use phpMyAdmin to look at your data. you'll need to have the propre code setting in the right most frame. then check what you see.
    If you find the &#3607;&# things, then that means that these characters are in the base (ie, &, #, 3, 6, 0, 7...)
    All is not lost... use the mulitbyte strings functions to convert your "iso-type" of string to utf-8.
    In some occasions, you'll need to do the reverse... so some trial and error seems required.

    I have tested displaying your codes in my own browser, they display fine  B-)) well they look like thai charcaters but I am not an expert...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    SQL injection vulnerabilities have been described as one of the most serious threats for Web applications. Web applications that are vulnerable to SQL injection may allow an attacker to gain complete access to their underlying databases. Because…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    857 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now