+254725682556 +254725052660 info@ziprof.co.ke
Client Area

Databases

How to Fix Garbled Text or Question Marks on Your Website Caused by Database Encoding Issues

If parts of your website show question marks, black diamonds, or strange symbols where normal text should be, especially in place of accented letters, currency symbols, or non-English characters, the problem is almost always a character encoding mismatch between your database and your website. The fix involves checking your site's expected encoding and correcting your database's charset and collation to match.

Why This Happens

Text is stored in your database using a specific character set (charset) and sorting rule (collation), such as utf8mb4_unicode_ci. If your website's code expects one encoding but the database table or column was created with a different one (a common issue on older sites or databases created with default settings), the browser displays the wrong bytes as garbled characters instead of the intended text.

Before changing any collation or converting data, back up your database first. Converting between encodings can occasionally corrupt already-garbled text if done in the wrong order, and a backup lets you undo the change safely. See how to back up a single MySQL database if you haven't already.

Step 1: Check What Encoding Your Website Expects

If you're running WordPress, open your wp-config.php file (via File Manager or FTP) and look for these lines:

  • DB_CHARSET, usually set to utf8mb4 or utf8
  • DB_COLLATE, which is often left blank so WordPress uses the default for that charset

For other platforms, check your database connection settings or config file for a similar charset value. Whatever value is set there is what your actual database tables need to match.

Step 2: Check and Fix the Database Charset and Collation

You'll do this in phpMyAdmin, which is reached the same way in both control panels for this purpose.

  1. Log in to your control panel and open phpMyAdmin (in cPanel it's under the Databases section; in DirectAdmin it's listed under MySQL Management).
  2. Select your database from the left-hand list.
  3. Click the Operations tab at the top.
  4. Under Collation, choose the correct charset and collation (for example, utf8mb4_unicode_ci) and click Go. This changes the default for new tables in that database.
  5. To fix an existing table, click the table name, go to its own Operations tab, and change its Table options: Collation the same way.
  6. If individual columns still show the wrong encoding after that, open the table's Structure tab, click Change next to the affected column, and set its collation there too.
Changing a table's collation reformats how MySQL interprets stored bytes going forward. It does not automatically rewrite text that's already garbled: if the wrong bytes were saved in the first place, you may need to restore that specific content from a backup taken before the corruption happened, then re-save it under the correct encoding.

Step 3: Confirm the Fix

After updating the collation, reload the affected pages in your browser (a hard refresh, or clearing your browser cache, helps rule out a cached copy of the old page). If new content you type now displays correctly but old content is still garbled, that older content was saved with the wrong encoding and needs to be corrected directly, not just reformatted.

If You're Not Comfortable Editing the Database Directly

Encoding fixes are one of the few database tasks where a small mistake can affect content across your whole site. If you're unsure at any step, it's worth having someone check the database structure with you rather than guessing on a live site.