2

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.

hakuna matata
  • 3,243
  • 13
  • 56
  • 93
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – deceze Jun 09 '13 at 19:28
  • [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/) – deceze Jun 09 '13 at 19:28
  • So, you have something that is recorded inside your database. That might be the good thing. But, have you set a character set that permits you to read those strings on the app that reads it after? – Deblaton Jean-Philippe Jun 09 '13 at 19:34
  • This is my first time using arabic text in my code, so I don't know if what I'm doing is right or not. But as I said, I read somehwere to put it to cp1256, which is arabic letters set for windows. – hakuna matata Jun 09 '13 at 19:39

1 Answers1

3

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.

echo_Me
  • 37,078
  • 5
  • 58
  • 78
  • I just noticed, that sometimes, when retrieving from the database, I get truncated strings, like I just get half of the string, why is that? and also, at a certain letter `ع` I get a small black square with question mark in it and stops at that place, why is that too? – hakuna matata Jun 10 '13 at 15:13
  • nice that it works for you to get data in arabic and save them to database by arabic , now i see its other questions wich im not really see where is problem but i can just give some notes . about truncated strings try look if in this column in database is limited varchar length. exemple if your string is 35 long and in database you defined varchar(25) so you get it truncated. about ع i say that all letters works normal only maybe there is with it some fatha or kasra or damma which maybe not reconized, you must check and debug why happening this , i never met those things. Thanks – echo_Me Jun 10 '13 at 16:40
  • About the truncated strings, I have the varchar length to be 100, and all strings are for sure less than 50 even. As for the not recognized letters, I'll make sure now about the punctuations to see if its because of it. Thanks for your reply – hakuna matata Jun 10 '13 at 16:50
  • I made sure there are no punctuations, but still I get the black diamond shape with question mark in it. – hakuna matata Jun 10 '13 at 20:23
  • sorry i dont know why , all works good just for letter ع , something wrong there . – echo_Me Jun 10 '13 at 20:27