Persian character's issue in mysql database

Viewed 5198

When I insert Persian data to database, data will save like this: †Ø¯Ø± 50 لیتری

But when I read data from database and echo it on the web, they are Ok.

I need to read data in my database directly. what is your solution?

Mysql setting:

Server connection collation: UTF8_general_ci

Html file charset is utf8.

5 Answers

You should change your collation to utf8_unicode_ci in your phpmyadmin:

  1. Go you your localhost/phpmyadmin
  2. Select your database
  3. Next to your database there's an small icon click on that
  4. Click on change
  5. Change your collation to utf8_unicode_ci.
  6. Insert this code to your php file.
if (!$connection->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
    exit();
} else {
    printf("Current character set: %s\n", $connection->character_set_name());
}
Related