UTF 8 - PHP и MySQLi UTF8
мой набор символов таблицы - utf8, и его сопоставление - utf8.now, у меня есть этот код:
<code> $mysqli = new mysqli("localhost", "root", "", "Amoozeshgah"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); } if (!$mysqli->set_charset("utf8")) { printf("Error loading character set utf8: %s\n", $mysqli->error); } else { printf("Current character set: %s\n", $mysqli->character_set_name()); } mysql_set_charset('utf8'); if ($stmt = $mysqli->prepare("SELECT About_Title FROM Tbl_About WHERE About_Id=?")) { $city = 8; /* bind parameters for markers */ $stmt->bind_param("s", $city); /* execute query */ $stmt->execute(); /* bind result variables */ $result = $stmt->get_result(); /* fetch value */ while ($myrow = $result->fetch_assoc()) { // use your $myrow array as you would with any other fetch printf("%s is in district %s\n", $city, $myrow['About_Title']); print("shod"); } </code>
но на выходе это:
<code>Current character set: utf8 8 is in district نتمنتشس shod </code>
Что я могу сделать? Редактировать: я заменил:
<code>if (!$mysqli->set_charset("utf8")) { printf("Error loading character set utf8: %s\n", $mysqli->error); } else { printf("Current character set: %s\n", $mysqli->character_set_name()); } mysql_set_charset('utf8'); </code>
с
<code>$mysqli->set_charset("utf8") </code>
но без разницы