PHP – MySQL and Unicode solution to marathi, Chinese, or any language

Its very simple and easy stuff, if you follow things as mentioned bellow. You may find same kind of code shared by other developer. This blog explains PHP – MySQL and Unicode solution to marathi, hindi, gujarathi,Chinese, rashiyan or any other regional languages.

Step 1: Most important is when you make database connection you have to mention “utf-8”.

$dbLink = mysql_connect(HOSTNAME, USERNAME, PASSWORD);
mysql_query("SET character_set_results=utf8", $dbLink);
mysql_select_db(DATABASE, $dbLink);
mysql_query("set names 'utf8'",$dbLink);

Step 2: html page header
Make sure that the html header “CHARSET IS SET TO UTF-8”.

Step 3: Data Manipulation statement i.e. insert and update statement.
Make sure that the character set is is uft-8.

mysql_query("SET character_set_client=utf8", $dbLink);
mysql_query("SET character_set_connection=utf8", $dbLink);
$insert_query = "INSERT INTO TABLE (field_one, field_two) VALUES('value_one', 'value_two')";
mysql_query($insert_query, $dbLink);

You are done with utf.

Share this nice post:

3 thoughts on “PHP – MySQL and Unicode solution to marathi, Chinese, or any language

  1. I really liked your web page. You actually come with very good posts. Thanks a bunch for revealing your web site.

  2. Excellent web site you have got here.. It’s difficult to find high-quality writing like yours these days. I really appreciate individuals like you! Take care!!

Comments are closed.