使用 php 将希伯来语插入 mysql 的问题
Problems with inserting hebrew into mysql using php
当我插入希伯来语时,它变成了גולדהמ×יר。
我尝试添加 mysql_query( "SET CHARACTER SET utf8" );到我的代码,它不起作用。
这是我的部分代码:
header('Content-Type: text/html; charset=utf-8');
mysql_query("SET character_set_client = utf8");
mysql_query("SET character_set_connection = utf8");
mysql_query("SET character_set_results = utf8");
$insertUser = $odb -> prepare("INSERT INTO `users` VALUES(NULL, :username, :password, :email, 1, 0, 0, 0, '', 0, :Name, :school, :class, 3, 0)");
$insertUser -> execute(array(':username' => $username, ':password' => SHA1($password), ':email' => $email, ':Name' => $Name, ':school' => $school, ':class' => $class));
看起来像 x 的字符是希伯来平面的转义符。
先看看:
http://php.net/manual/de/function.utf8-decode.php.
勾选 collation_connection:
show variables like '%collation%'
如果 utf8-decode 不起作用,评论中的功能之一可能会起作用。请务必为 PHP.
使用多字节字符集
也可以查看;在 conn.inc.php
文件中,选择数据库并连接到它后,执行以下操作:
if(!mysqli_set_charset($conn, 'utf8')) {
echo 'the connection is not in utf8';
exit();
}
并且在 html 中始终使用字符集 utf-8;
如果这些都不适合你;请 google 在 mysql Whosebug 中使用 希伯来语;你会得到很多文章;这可能会解决您的问题。
另请参阅:UTF-8 all the way through
当我插入希伯来语时,它变成了גולדהמ×יר。 我尝试添加 mysql_query( "SET CHARACTER SET utf8" );到我的代码,它不起作用。
这是我的部分代码:
header('Content-Type: text/html; charset=utf-8');
mysql_query("SET character_set_client = utf8");
mysql_query("SET character_set_connection = utf8");
mysql_query("SET character_set_results = utf8");
$insertUser = $odb -> prepare("INSERT INTO `users` VALUES(NULL, :username, :password, :email, 1, 0, 0, 0, '', 0, :Name, :school, :class, 3, 0)");
$insertUser -> execute(array(':username' => $username, ':password' => SHA1($password), ':email' => $email, ':Name' => $Name, ':school' => $school, ':class' => $class));
看起来像 x 的字符是希伯来平面的转义符。 先看看: http://php.net/manual/de/function.utf8-decode.php.
勾选 collation_connection:
show variables like '%collation%'
如果 utf8-decode 不起作用,评论中的功能之一可能会起作用。请务必为 PHP.
使用多字节字符集也可以查看;在 conn.inc.php
文件中,选择数据库并连接到它后,执行以下操作:
if(!mysqli_set_charset($conn, 'utf8')) {
echo 'the connection is not in utf8';
exit();
}
并且在 html 中始终使用字符集 utf-8;
如果这些都不适合你;请 google 在 mysql Whosebug 中使用 希伯来语;你会得到很多文章;这可能会解决您的问题。
另请参阅:UTF-8 all the way through