Настройка кодировки Mysql и Mysqli
MYSQL
mysql_connect($hostname, $username, $password) or die ("Не могу создать соединение");
mysql_select_db($dbName) or die (mysql_error());
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
mysql_query("SET SESSION collation_connection = 'utf8_general_ci'");
MYSQLI
$mysqli = new mysqli( $host, $user, $password, $database );
$mysqli -> query("SET NAMES 'utf8'");
$mysqli -> query("SET CHARACTER SET 'utf8'");
$mysqli -> query("SET SESSION collation_connection = 'utf8_general_ci'");