title: MySQL and PHP: UTF-8 with Cyrillic characters
body: <p>I'm trying to insert a Cyrillic value in the MySQL table, but there is a problem with encoding.</p>
  
  <p>Php:</p>
  
  <pre><code>&lt;?php
  
  $servername = "localhost";
  $username = "a";
  $password = "b";
  $dbname = "c";
  
  $conn = new mysqli($servername, $username, $password, $dbname);
  
  mysql_query("SET NAMES 'utf8';"); 
  mysql_query("SET CHARACTER SET 'utf8';"); 
  mysql_query("SET SESSION collation_connection = 'utf8_general_ci';"); 
  
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $sql = "UPDATE  `c`.`mainp` SET  `search` =  'test тест' WHERE  `mainp`.`id` =1;";
  
  if ($conn-&gt;query($sql) === TRUE) {   
  }
  $conn-&gt;close();
  
  ?&gt;
  </code></pre>
  
  <p>MySQL:                                     </p>
  
  <pre><code>| id |    search   |            
  | 1  |   test Ð°Ð² |
  </code></pre>
  
  <p>Note: PHP file is <code>utf-8</code>, database collation <code>utf8_general_ci</code></p>