Question

I’m working on a project; I need to save some fields like having arabic character like first_name, last_name. The form is posting all other fields correctly except these fields.

I directly saved arabic words in database table but still it is showing ???? instead of original words.

I’m using Charset utf8 and Collation utf8_unicode_ci with these fields. Also on header I’ve <meta charset="utf-8" />

I think it is some configuration issue of Cakephp because database seems okay. I’ve tried this so far, it is not working.

<h1 lang="ar"><?php echo $user['User']['first_name_ar']; ?></h1>

This is my database.php

public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'root',
        'password' => '************',
        'database' => 'projectimpossible',
        'prefix' => '',
    );

Thanks in advance.

Was it helpful?

Solution

It seems like your database configurations defined in database.php under Config folder is incorrect. Here encoding should be utf8 as well.

public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'root',
        'password' => '************',
        'database' => 'projectimpossible',
        'prefix' => '',
        'encoding' => 'utf8',
    );

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top