P
P
Peter2014-05-22 14:43:33
PHP
Peter, 2014-05-22 14:43:33

How to solve output encoding problems?

Greetings.
This is a continuation of the question Encoding problems
In the previous question, we have already figured it out and got:
1. Base in utf
2. Data written in utf (including Cyrillic displayed correctly)
3. Encoding when accessing the database - utf
What was my surprise when after such a triumph, the select wardump from the database issued: �����������
mb_detect_encoding data from the database showed that it was UTF-8. But, damn it, how is that?!
Structure screen:
c095a64a6be148589e2160ab612530d0.pngData screen : Database
e99b2efd2b5e434fafc30e698a61d470.pngconnection:

$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
    'dbs.options' => array(
        'local' => array(
            'driver' => 'pdo_mysql',
            'host' => 'localhost',
            'dbname' => '***',
            'user' => '***',
            'password' => '***',
            'charset' => 'utf8',
        ),

Table encoding:
82f65abd1027411eb215ac95c4cb065e.pngData is written as follows:
$con = mysqli_connect("***");
mysqli_query($con, "SET NAMES 'utf8';"); 
mysqli_query($con, "SET CHARACTER SET 'utf8';"); 
mysqli_query($con, "SET SESSION collation_connection = 'utf8_general_ci';");
mysqli_query($con,"INSERT INTO api_response (response) VALUES ('" . $response . "')");

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Solovyov, 2014-05-22
@Alcospb

the table itself and the database in utf-8 encoding?

C
corsar100, 2014-05-22
@corsar100

mysqli_set_charset($con, 'utf8');

<head>
  <meta charset="utf-8">
</head>

I would also like to save all files in UTF-8 without BOM

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question