var $link = $("#frametest").contents().find(".eod-topbox").find('a');
var variable2= $("#frametest").contents().find(".eod-topbox").find("h3").find(".hidetitle").html();
var variable1= $link.attr('href');
$.post('insert.php', {variable1: link_address, variable2: heading},
function(data){$("#message").html(data);});
alert(variable2);
alert(variable1);
在此脚本中,alert
正确显示印地语文本并显示链接。但是当我尝试将此variable2
保存到数据库时,它会保存如下内容
कांगà¥à¤°à¥‡à¤¸ से बढ़ती AA...
在消息中div
印地语文本显示正确,当我手动将印地语文本复制到数据库时没有问题。请帮助某人。
您的数据库列排序规则应utf8_unicode_ci
并将此代码放在 PHP 页面的顶部
mysqli_set_charset ($con, "utf8");
和地方
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
在您的 HTML 标头中
这就是我通常在连接文件中执行的操作:
$db = new mysqli($db_host, $db_user, $db_pass, $db_name);
if ($db->connect_errno) {
printf("Connect failed: %sn", $db->connect_error);
exit();
}
$db->query("set names 'utf8'");