php - 阿拉伯语语言转换 php 到 mysql

标签 php mysql utf-8 arabic

<分区>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
mysql_query("update `mudasser`
             set `name`='$name',
                `ar_name`='$ar_name',
                `address`='$address',
                `type`='$type',
                `telephone`='$telephone',
                `date_added`='$date',
                `image`='$file'
            where `id`='$id'"

当我回应查询时,这就是结果

update `mudasser` set `name`='Boknan', `ar_name`='بوكنان', `address`='E2', `type`='Abaya Galabia', `telephone`='2535338', `date_added`='2015-06-01 08:54:11', `image`='Boknan.jpg' where `id`='128'

可以看到阿拉伯文名字显示正确 但在数据库中,阿拉伯文名称有点像这样 ???????

如果我直接在 mysql 中运行这个查询,它运行完美,它也在 php 页面中读取正确的阿拉伯语。

作为引用,我正在使用 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">在 php 中,也在 db 中使用 utf-8。

我已经搜索过网络和 Stackoverflow,但找不到任何答案。

最佳答案

在执行更新查询之前尝试这个。

要么

mysql_query("SET NAMES utf8");

mysql_query("SET NAMES utf8mb4");

utf8mb4 是首选。在 MySQL 5.3.3 中引入,如果可能的话使用它。

read more about difference in UTF8 and UTF8mb4 and how to switch to mb4

关于php - 阿拉伯语语言转换 php 到 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30574204/

相关文章:

php - 如何在 MySQL 查询中传递 & 符号?

php改变多维数组的值

Mysql子查询锁定

php - 有没有办法防止表透视/映射中出现重复条目​​?

php - 数据库设计 : foreign keys and normalization

wordpress - 输入希伯来语时,PayPal 捐赠说明显示断线字符

PHP: Prepared statements (newbie), 只需要确认一下 SQL injection

php - 如何从 Eloquent 关系中限制选定的列?

node.js - Node : Express: How to handle application/octet-stream;charset=;UTF-8 response?

linux - 如何在 Linux 中检查文件的字符编码