Arabic strings from php to MySQL tables

久未见 提交于 2019-12-22 14:05:12

问题


I have an array of Arabic strings, and I want to add them to my tables in MySQL. I can display the strings using the php print normally, however, when I add this string to the table using PDO, in phpMyAdmin, I see the record of this string as a bunch of question marks (?) and other characters. I looked around for what is happening, and one of the things I saw was to change the collation to cp1256_general_ci however this keeps the same things, a bunch of question marks (?) and other characters.

I was using MAMP on mac, but because I read that cp1256 is windows, I am using XAMPP on windows now.

How can I add the Arabic strings to the table, and be able to see them in phpMyAdmin normally?

EDIT:

I tried to query the table with the weird strings to see if it works, but I got black rhombus shapes and question marks.


回答1:


you have to do those three things and there you go

  • 1- change the encoding of your editor programm which you use to UTF-8 .

  • 2- put in your php files this

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    
  • 3- put the collation in your database to UTF-8

in conclusion use UTF-8 everywhere.



来源:https://stackoverflow.com/questions/17013298/arabic-strings-from-php-to-mysql-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!