MySQL和PHP:utf-8带有西里尔字符
<?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->connect_error) { die("Connection failed: " . $conn->connect_error);} $sql = "UPDATE `c`.`mainp` SET `search` = 'test тест' WHERE `mainp`.`id` =1;";if ($conn->query($sql) === TRUE) { }$conn->close();?>
| id | search | | 1 | test ав |
utf-8
utf8_general_ci
子衿沉夜