1

My database is totally utf8mb4_unicode_ci encoded but when I try to echo character with accent mark like è ù... it doesn't print (or "send") anything at all.

PHP API

  ob_start();
  $Connection = new Connection();
  $zones = $Connection->arrCol("SELECT [...]", "column_name");
  ob_end_clean();
  header('Content-Type: application/json; Charset=UTF-8');
  echo json_encode($zones);

that's my function which put mysql table column inside an array

public function arrCol($query, $column)
    {
        if ($result = $this->conn->query($query))
        {
        $n=0;
            while ($row = $result->fetch_assoc())
            { 
            $ar[$n]=$row[$column];
            $n++;
    }
        return $ar;
        }
        else
    {echo "Error: " . $query . "<br>" . $this->conn->error; }

    }
  • 1
    You may edit your php file in Notepad++ then you change your file encoding With tab Encodeing->Encode In UTF-8 and Save n Try. – Santosh Jun 08 '17 at 11:09
  • 1
    I have previously written [**an answer**](http://stackoverflow.com/questions/31897407/mysql-and-php-utf-8-with-cyrillic-characters/31899827#31899827) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [UTF-8 All the Way Through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). Most likely, you'll find a solution in either one or both of these topics. – Qirel Jun 08 '17 at 11:16
  • 1
    Have u checked the AddDefaultCharset of Apache Server ? – mlwacosmos Jun 08 '17 at 12:19

0 Answers0