Encoding Issues When Working With SQL in PHP
As a rule, if no additional actions are taken, Russian text retrieved from the database will be displayed as gibberish or question marks. To avoid such problems, follow the rules described below.
Rule 1
The database and its tables should be in
the utf8_general_ci encoding.
Rule 2
The PHP file itself should be in utf8 encoding.
Rule 3
The following HTML tag should be at the beginning of the PHP file:
<meta charset="utf-8">
Rule 4
Just in case, immediately after the mysqli_connect
command, add the following query:
<?php
mysqli_query($link, "SET NAMES 'utf8'");
?>