当我试图将西里尔文本插入MySQL数据库时,它会像这样插入:
г???????????? ?? ????????
Рісѓрїр°ріс‹рї р° с‹рір°рї
所以我有两个页面:registration.php 和 addUser.php。每个页面里面都有该问题。
Рісѓрїр°ріс‹рї р° с‹рір°рї
所以我有两个页面:registration.php 和 addUser.php。每个页面里面都有该问题。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
数据库由11个表组成,每个表的排序规则为:utf8_general_ci,类型为:MyISAM。每个表中的每个字段都有排序规则:utf8_general_ci。
当我直接在phpMyAdmin中向数据库写入数据并将这些数据显示到网页上时,英语和俄语都没问题。
但是,当我在registration.php中填写个人资料,并转到addUser.php时,所有的Cyrillic字符都像我之前写的那样在页面上显示,而且在数据库中也是这样。
function AddNewUser($Name, $Surname, $FatherName, $Email, $Password, $Phone, $DegreeID, $RankID,
$Organization, $Department, $Country, $City, $Address, $Job)
{
//fetch data from database for dropdown lists
//connect to db or die)
$db = mysql_connect($GLOBALS["gl_kussdbName"], $GLOBALS["gl_kussUserName"], $GLOBALS["gl_kussPassword"] ) or die ("Unable to connect");
//to prevenr ????? symbols in unicode - utf-8 coding
mysql_query("SET NAMES 'UTF8'");
//select database
mysql_select_db($GLOBALS["gl_kussDatabase"], $db);
$sql = "INSERT INTO UserDetails (
UserFirstName,
UserLastName,
UserFatherName,
UserEmail,
UserPassword,
UserPhone,
UserAcadDegreeID,
UserAcadRankID,
UserOrganization,
UserDepartment,
UserCountry,
UserCity,
UserAddress,
UserPosition)
VALUES(
'".$Name."',
'".$Surname."',
'".$FatherName."',
'".$Email."',
'".$Password."',
'".$Phone."',
'".$DegreeID."',
'".$RankID."',
'".$Organization."',
'".$Department."',
'".$Country."',
'".$City."',
'".$Address."',
'".$Job."'
);";
//execute SQL-query
$result = mysql_query($sql, $db);
if (!$result)
{
die('Invalid query: ' . mysql_error());
}
//close database = very inportant
mysql_close($db);
}
?>
在phpMyAdmin中也有这样的信息:
auto increment increment 1
auto increment offset 1
autocommit ON
automatic sp privileges ON
back log 50
basedir \usr\local\mysql-5.1\
big tables OFF
binlog cache size 32,768
binlog format STATEMENT
bulk insert buffer size 8,388,608
character set client utf8
(Global value) cp1251
character set connection utf8
(Global value) cp1251
character set database cp1251
character set filesystem binary
character set results utf8
(Global value) cp1251
character set server cp1251
character set system utf8
character sets dir \usr\local\mysql-5.1\share\charsets\
collation connection utf8_general_ci
(Global value) cp1251_general_ci
collation database cp1251_general_ci
collation server cp1251_general_ci
completion type 0
concurrent insert 1
我需要正确地显示、保存和从数据库中选择俄语文本。谢谢! 连接超时时间为10秒。 数据目录为\usr\local\mysql-5.1\data\。