Back to Top

Special Characters Problem (Displaying ‘???’)

Updated 11 June 2014

Special characters are important to our web. We used them in different ways but If our webpage is not supporting Special characters or showing ???? instead of ‘ 中國哲學書電子化計劃 ‘ or ‘ בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם ‘ then it’s mean our controller / database is not properly working with these type of texts.

Reason can be behind this condition –

One reason – your database table / column collation is not correct like not UTF-8 or others those one support special chars.

How to solve this issue – 

You can use utf8_encode function which will convert your special characters to utf8 encoding data and then save it in your database and again use utf8_decode function to get special data back.

Searching for an experienced
Opencart Company ?
Find out More

Or just change your table or column collation type

$special_char = '中國哲學書電子化計劃';

// just use this 
$special_char = utf8_encode($special_char);

// then insert it into db (use your query type)
mysql_query("INSERT INTO `TABLE_NAME` SET special_char = '".$special_char."'");

// Opencart
$this->db->query("INSERT INTO `".DB_PREFIX."TABLE_NAME` SET special_char = '".$special_char."'");

// And when you fetch data then just use opposite of utf8_encode
// like your result in $special_char_result
$special_char_result = utf8_decode($special_char_result);

// this variable will display special char. text not  ????

// or another simple solution for this situation is just change the collation type of table or that particular column
// just run this query
mysql_query("alter table `TABLE_NAME` convert to character set utf8 collate utf8_unicode_ci");

// Opencart
$this->db->query("alter table `" . DB_PREFIX . "TABLE_NAME` convert to character set utf8 collate utf8_unicode_ci");

// From now on just add any special chars in db and retrieve without '????' fear.

That`s it !!! I hope it will help someone. 🙂 [stextbox id=”info”]Your opinions, comments and suggestions are important to keep the page updated and interesting. [/stextbox]

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home