Thursday, August 4, 2016

MySql PHP UTF8 Problem - CakePHP

If you are having a problem using Special Characters i.e. German Umlauts ö, ä, ü, ß etc in MySql Databases and accessing them in PHP Web Application, make sure you have don the following steps.

1. Choose utf8 as defaul Collation while CREATING DATABASE
2. Choose utf8 as defaul Colaltion / Characterset while CREATING TABLES
3. If you are importing data into your tables from some files, make sure they are saved in UTF8 format.

On you Web Application Side.
1. Make sure you have <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> in your head section of your page where you want to display these SPECIAL CHARACTERS.
2.  use SET NAMES utf8 in your MySql Connection String

Note. in Cake PHP Config -> database.php you should add 'encoding' => 'utf8'.

Now check the Result if your problem is not solved please comment and share your problem. Thanks for visiting.