西里尔语没有在MySQL中显示

时间:2014-03-06 14:12:06

标签: php mysql

当我通过PHP插入西里尔文本时,它会插入一行,但记录为空:

<?php

$link = new mysqli('localhost', 'xxx', 'xxx', 'xxx');

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* change character set to utf8 */
if (!mysqli_set_charset($link, "utf8")) {
    printf("Error loading character set utf8: %s\n", mysqli_error($link));
} else {
    printf("Current character set: %s\n", mysqli_character_set_name($link));
}

if($link->connect_errno > 0){
    die('Unable to connect to database [' . $link->connect_error . ']');
}

mysqli_query($link, "INSERT INTO applications (firstname, lastname, university, specialty, course, hobby, motivation, phone, email) VALUES ('да', 'да', 'да', 'да', 'да', 'да', 'да', 'да', 'да')");

mysqli_close($link);

?>

当我删除/ *更改字符集为utf8 * /条目是符号时......问题出在哪里?

1 个答案:

答案 0 :(得分:0)

连接到数据库后调用此方法:

mysql_query("SET NAMES UTF8");

Source