duanliao5995 2015-06-01 13:00
浏览 27
已采纳

阿拉伯语语言转换php到mysql [重复]

This question already has an answer here:

<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'"

when i echo the query this is the result

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'

You can see the arabic name appearing correct but in the database the arabic name is somehow like this ???????

If i run this query directly in mysql, it runs perfect and it is also reading correct arabic in php page.

For reference i am using <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> in php and also using utf-8 in db.

I have searched the net and Stackoverflow but i cant find any answer.

</div>
  • 写回答

3条回答 默认 最新

  • dtc9222 2015-06-01 13:06
    关注

    Try this before executing the update query.

    either

    mysql_query("SET NAMES utf8");
    

    or

    mysql_query("SET NAMES utf8mb4");
    

    utf8mb4 is preferred. Which was introduced in MySQL 5.3.3, use it if possible.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?