问题
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