L
L
Lumore2014-11-19 17:50:13
MySQL
Lumore, 2014-11-19 17:50:13

Why are krakozyabry displayed from the database?

Help to correctly display content from the database, a site on Denver. Encoding - utf8.
I did this:
header('Content-Type: text/html; charset=utf-8');
To get posts:

function get_posts() {
  global $mysqli;
  $sql = "SELECT * FROM posts";
  $result = $mysqli->query($sql);
  $result = mysqli_fetch_assoc($result);
  return $result;
}

And output:
foreach($posts as $post) {
  echo '
  <div class="post">
    <div class="post-author"><a href="/profile.php?id='.$post['author-id'].'">'.$post['author-name'].' '.$post['author-surname'].'</a></div>
  </div>
  ';
}

The following characters come out: � �. The database encoding is utf8_general_ci.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Arkhipov, 2014-11-19
@arvitaly

php.net/manual/ru/mysqli.set-charset.php

I
Ilya Plotnikov, 2014-11-19
@ilyaplot

Change php file encoding to utf8

V
Vladimir, 2014-11-19
@rostel

If as a web server apache2, it can transcode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question