Ti Amo Laky
Ti Amo Laky

Reputation: 765

Display data with accent french in cakephp

I have data with accents in my database. like image below enter image description here

when I want to display the data with my controller it gives me this Here is the code

header('Content-Type: text/html; charset=utf-8');
$icozim=$this->Icozim->find('all');
debug($icozim,0,0);

when I run my function I have this enter image description here

How can I solve this problem?

sql for my table is

    CREATE TABLE `icozims` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `synonymes` MEDIUMTEXT NOT NULL,
    PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

Upvotes: 2

Views: 1000

Answers (2)

Fury
Fury

Reputation: 4776

There are several things that you have to cover. All of these Encode has to be the same (assigned properly). then you can retrieve symbols or special characters properly.

  1. Encode that you are using for Database

  2. At the same time Encode you are using for Table

  3. Encode of your HTML header

  4. Encode of php code when ever you are retrieving/ printing / saving your data. Also there are some functions that you can play around which does that for you. e.g. mb_convert_encoding($value, 'UTF-8', 'HTML-ENTITIES')

  5. If you are using any kind of frameworks you might need to set the Encode in core class

  6. If your data has been saved with this specific symbol then you will need to edit all of them or write a function to convert them to a symbol or character you want to show. I remember I had the same problem with one of my project with wordpress which we removed all manually but after that I find an article that there was a plugin which sort out that problem automatically for you.

Upvotes: 0

timstermatic
timstermatic

Reputation: 1740

In your APP/Config/database.php look for the line:

// 'encoding' => 'utf8',

and uncomment it.

Upvotes: 4

Related Questions