我想使用 pdo 和 php 将阿拉伯字符插入数据库,但我在数据库中得到了这些字符
الجامع ا
当我使用
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
结果是
??????????
我在 phpMyadmin 中收集列
utf8mb4_unicode_ci
和这个
utf_unicode_ci
但我仍然有同样的错误。
我试着像这样建立联系:(totti,totti 不是我真正的用户名和密码)
parent::__construct('mysql:host=localhost;dbname=ams-competation;charset=utf8"', 'totti', 'totti');
但我仍然得到同样的错误
我也试过这样:
parent::__construct('mysql:host=localhost;dbname=ams-competation;charset=utf8', 'totti', 'totti'
,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
并且不起作用:(
在提交表单之后,在插入数据库之前,我回显了这些值并且我得到了阿拉伯字符,这意味着我的问题出在数据库中,但是回显只是在不使用 meta 的情况下工作
当我尝试从 phpmyadmin 插入阿拉伯字符时,它可以工作
我在用
phpmyadmin in XAMPP 1.7.4
php 5.5.3
最后我找到了解决方案,它是:
- 收集 utf8_unicode_ci 列
- 放入
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
标题