Skip to main content

Storing unicode texts in MySQL with phpMyAdmin

Today, I've received a personal mail/request from Sivanantham Hemamalini, working for IT leisure in Singapore. Since I was in company when received the mail, I couldn't answer immediately. If I understand the question right, it is about inputting Unicode texts especially Tamil in phpMyAdmin.

PhpMyAdmin's default characterset is iso-8859-1 and so if we enter anything in the form, browser will convert it into numerical html entities. Say for example, if we enter தமிழ் and submit the form, it will convert it to & #2980;& #2990;& #3007;& #2996;& #3021;. Because of this browser's behavior, it will be difficult to store the Unicode text as it is.

Solutions

Immediate solution I could think of is changing or forcing the browser's character encoding into utf-8. In Mozilla Firefox, it can be set via View -> Character Encoding -> Unicode (UTF-8)

Another elegant solution might be changing the phpMyAdmin configurations so that it sends and sets proper charset in Content-Type header as Content-Type: text/html; charset=utf-8
To do this, we have to edit the config.inc.php file found at phpMyAdmin's root directory:
$cfg['DefaultCharset'] = 'utf-8'; and
$cfg['AllowAnywhereRecoding'] = true;
These change of configurations should send proper headers. Anyhow, if the lang cookie is already set to some other charset, it won't reflect the changes. So, one may need to clear the cookies to see the changes.

Comments

Anonymous said…
I edit the config.inc.php file to this,
$cfg['DefaultCharset'] = 'utf-8'; and
$cfg['AllowAnywhereRecoding'] = true;
But i am getting error stating "Can not load iconv
or
recode extension needed for charset conversion,
configure php to allow using these extensions or
disable charset conversion in phpMyAdmin."
what is the solution for this.
I am using windows XP and php,v 2.8.2.1
thanks in advance
Hema
Hema, as the error message says it couldn't load the iconv extension, as it is not enabled. You can enable and disable PHP extensions via php.ini configuration file.

Use phpinfo() function to find the path of php.ini file.
To enable the iconv extension, just uncomment the line ;extension=php_iconv.dll (that is just remove the leading semicolon ";") in php.ini
You may need to restart Apache for the changes to reflect. Again use phpinfo() to see if the module is enabled or not. Now, you're done.

This procedure applies to any PHP extensions on Windows.
Anonymous said…
Do you have to use phpMyAdmin? I would write a simple PHP script to accept the input correclty and post to the db. The other solutions sound like more work.

Popular posts from this blog

jobreapr, search better fiverr alternatives at one place

Sometime ago, I blogged that FPPlatform is ahead of other Fiverr clone scripts . FPPlatform, aka Fixed-price platform is a freelance job platform written in PHP/MySQL stack that our team has developed. It's powering many good fiverr alternatives. The panic fiverr then tried to close the competitors through PayPal's AUP through false copyright claim--the problems were sorted out through legal measures of the competitors and I hope, fiverr will be forced to pay damages for alleged copyright claim. Problems with Fiverr For sellers, Fiverr charges hefty 20% commission. There are bunch of related complaints about fiverr on the net. Also, on the net can find many buyers complain that sellers in Fiverr are not serious as they would be getting just $4 for every services; sellers have to focus on quantity--not quality to make profit. Better Fiverr alternatives FiverrWay , tracks all fiverr competitors and also publishes rank every month. Being competitors, these sites takes lot of mea...

Amazon India Prime Offer - A scam or a bug?

TLDR; Amazon.in shows and sends me a Prime offer that I can't avail (it leads to an error message) I have escalated this issue to Amazon India through various means, but the team wants screenshots (even after sharing them through Twitter) and so here's the post explaining that... 1. Amazon India sends me an email: Your Prime membership ends soon - Renew early to lock in old price of ₹999 1499 for another year of Prime. The newsletter comes like this: Rajesh, Renew Prime early and save ₹500 Your Prime membership ends soon Renew today Expiring soon DON'T GO A DAY WITHOUT PRIME! Your Prime membership ends soon - Renew early to lock in old price of ₹999 1499 for another year of Prime. Continue enjoying uninterrupted Prime benefits. Renew today Kindly ignore if you have already availed this offer. Please note that pro...

Spotify's Greenroom Vs. Clubhouse - Missing Text Chat and Other Impacts

We have Clubhouse clones from Twitter, Facebook, Reddit, and now Spotify. Unlike others, Spotify seems to target directly into the Clubhouse audience/members. It is extremely obvious inside Clubhouse as you can find many spammy clubs and rooms created to attract the Clubhouse users. Greenroom Vs. Clubhouse I was stumbled upon one such room Clubhouse influencers are jumping off to Greenroom? - All things Hollywood . Few takeaways from the room are: Text chat is not available in Clubhouse, whereas it is available in Greenroom. This is the most talked-about USP. The recording feature is not available in Clubhouse and the same is available in Greenroom. Spotify has opened up a creator fund for Greenroom creators in the USA. However, I think, there are better indirect monetization options available for Clubhouse users. Stream's chat component & million-dollar opportunity? As I tweeted , Clubhouse can quickly bring the text chat feature by using Stream's chat component . If they...