Not showing persian data correctly

Website URL

radico.epizy.com

Error Message

The problem is that the site doesn’t show the data with persian characters from database correctly. The collation is utf8 general ci. And I tested the code with xampp with the same settings and everything was alright it might be some sort of problem in host settings. Can you help about that?

Other Information

The first entry is 1101
The second is 2742607331 then enter
You can see two of them that are persian characters are question marks

If I understand this correctly: you entered the data through phpMyAdmin, and it shows correctly there. But you query the data from your website, and it doesn’t show it correctly there?

If so:

You’re looking for the right thing, but in the wrong place. Collation affects how data is indexed on disk, but seeing how it is shown differently in different places, collation is not the issue.

I suspect the issue is caused by the database charset of your MySQL connection in PHP. phpMyAdmin uses utf8 (or utf8mb4) for this, but PHP is configured to use latin1 by default. So data entered with phpMyAdmin will be garbled on your site, and vice versa.

To fix this, you should always set the charset of the database connection in your code. utf8mb4 is always a good choice for this.

If you use MySQLi: PHP: mysqli::set_charset - Manual

If you use PDO: PHP: PDO_MYSQL DSN - Manual

5 Likes

Yea, thanks it got solved. I suspected that but couldn’t change it correctly till visiting the document you sent.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.