0

I was previously using Namecheap hosting servers to run my website (https://www.bilawalcoachingcenter.com) and now shifted on Site Ground. The problem is that the words of the Urdu language, that were stored in the database, are not displaying properly. Instead of the words, it is showing me the encoding.

Here is the setup of my HTML page:

<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

That's how I'm connecting through PDO:

$this->_pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/db'), Config::get('mysql/username'), Config::get('mysql/password'));

The Server Connection Collation at Site Ground is utf8mb4_unicode_ci (same as on Name Cheap)

Kindly help me to solve this problem.

Test Page: https://www.bilawalcoachingcenter.com/vocabulary.php

  • It's hard to say what's wrong. I'd also say that 'showing you the encoding' doesn't sound like the right phrase. Everything is 'encoded'. It's possible that it was already incorrectly stored when you first inserted it into MySQL. – Evert Oct 25 '21 at 16:56
  • 1
    The accepted answer here has some more background: https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Evert Oct 25 '21 at 16:57
  • Thank you so much for showing me the possible solutions/things. – Mohsin Ahmed Oct 27 '21 at 20:19
  • It was quite weird because everything seemed to be similar on both servers. Then suddenly I came to know that the encoding of table columns is not utf8 on the new server. That was strange to me because I just imported the database from the previous server. Didn't know how it changed. I was struggling for a week to get it solved, and when I found this, I was about to destroy my laptop!!! – Mohsin Ahmed Oct 27 '21 at 20:21
  • So you solved your problem? If yes, that's great news! – Evert Oct 27 '21 at 20:22

1 Answers1

0

Resolved

It was quite weird because everything seemed to be similar on both servers. Then suddenly I came to know that the encoding of table columns is not utf8 on the new hosting server. That was strange to me because I just imported the whole database from the previous server. The server collation was utf8mb4_general_ci, the table's collation was the same, but the collection for table columns was different. Don't know how it got changed. I was struggling for a week to get it solved, and when I found this, I was about to destroy my laptop!!!