PHP / MySQL Encoding

I have a website with Arabic content that has been migrated from another server. Everything was displayed correctly on the old server, presumably everything was encoded in UTF-8.

On the current server, data began to display incorrectly, showing Ü † Ø¨Ø ° Ø © ع٠† and similar symbols.

The application is based on CakePHP Framework.

After many tests, I changed the parameter 'encoding'in the MySql connection array to become latin1 . For people who don’t know CakePHP, this sets up the MySql connection encoding. Setting this value to UTF8 did not change anything even after the steps described below.

Some of the entries began to display correctly in Arabic, while others remained gibberish.

I have already passed the verification of the entire database and server, confirming that:

  • The created database is UTF-8.
  • UTF-8 table.
  • The columns do not explicitly indicate any encoding encoded in UTF-8.
  • The default character set in PHP is UTF-8
  • Mysql.cnf default settings for UTF-8

After that, I extracted my data and stuck on it, printing the encoding of each line (from each line) with mb_detect_encoding. Lines that display correctly return UTF8 until they return nothing for damaged lines.

- , , . , 2 , , - UTF-8 latin1.

, mb_detect_encoding , ?

UPDATE: , , , my.cnf . :

- = utf8

- = utf8

, , .

, , , , , , , .

+4
3

.. php

UTF8

. , ( phpmyadmin) .

,

  • php

  • html

, ..

Edit:

, , ,

0

نبذة عن? . . duplicate , , ALTER TABLEs.

0

I had a similar problem with migrating database tables encoded with using utf8from a shared server to localhost. The resolution was to set the local server encoding using PHP

$db->set_charset("utf8") 

immediately after the connection mysqli.

Now it works correctly.

0
source

All Articles