你好iam真的在努力解决这个问题
我有一个脚本可以将阿拉伯字母插入数据库
我的数据库和表格是utf-unicode_ci
$title = make_safe($_POST['title']);
$author = make_safe($_POST['author']);
$category = make_safe($_POST['category']);
$meta = str_replace(array('-', ' ', '*'),",",make_safe($_POST['meta']));
if ($title == "" OR $author == "" OR $category == "")
{
echo $lang['STORY_FIELDS_MUST_FILL'];
echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL= stories.php?action=add'>";
}
else
{
$stmt = $db->prepare ("INSERT INTO stories (title,author,category,meta,date)
VALUES (:title,:author,:category,:meta)");
$stmt->execute(array(':title' => $title,
':author' => $author,
':category' => $category,
':meta' => $meta));
echo "$lang[STORY_ADDED]";
echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL=" . $_SERVER['HTTP_REFERER'] . "'>";
}
添加文章时,这个php代码在phpmyadmin中显示如下
当我通过Phpmyadmin
插入值时它显示这样,一切都很顺利
如何通过php代码添加它以显示相同,例如从phpmyadmin
添加它答案 0 :(得分:0)
感谢解决方案在连接代码之后执行此
$ pdo-&gt; exec('SET NAMES \'utf8 \'COLLATE \'utf8_unicode_ci \'');