APK errors

In PHP the letter ə becomes a question mark

Two places are separate. The page has to say what it sends to the browser. The database connection has to say how it writes the text.

Without the header the browser may read the page with the system table. Without charset on the connection MySQL may treat the text as latin1. On both paths ə becomes ?.

The file itself must be saved as UTF-8. A PHP header does not repair the bytes inside the file.

  • At the start of each page put header("Content-Type: text/html; charset=utf-8").
  • In the PDO string write charset=utf8mb4. A DSN without charset can turn ə into ?.
  • If you use mysqli, after connecting call mysqli_set_charset($baglanti, "utf8mb4").
  • Save the .php file as UTF-8. If the editor picked ANSI, the letter never entered the file.
  • If the letter in the table is already ?, changing the header does not bring it back. Write the row again.
<?php
header("Content-Type: text/html; charset=utf-8");
$baglanti = new PDO(
    "mysql:host=127.0.0.1;dbname=magaza;charset=utf8mb4",
    "root",
    ""
);
echo "Azərbaycan";

Related guides