0

I have a .CSV file that have an arabic data and i need to import this file into the sql database using PHP. my code doing it just fine except that the arabic characters inserted into the database as 'ËËËË','ÚÚÚÚ'.

what should i do to insert that data right.

any ideas?

 $filename = $_FILES['upload']['tmp_name']; 
 $file = fopen($filename, "r");
  while (($emapData = fgetcsv($file, 1000, ";")) !== FALSE){
  $emapData[0];
  var_dump($emapData[0]);   //'ËËËË','ÚÚÚÚ'
  }
nashwa
  • 221
  • 1
  • 2
  • 17
  • 3
    Sounds like an encoding issue. Please start here: http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – arkascha Oct 10 '16 at 13:30
  • the problem is in reading the file because the result of the previous `var_dump()` is `ËËËË','ÚÚÚÚ` before i insert it into the database .. i need to read the data in the file in a correct way. – nashwa Oct 10 '16 at 13:53
  • Sounds like the encoding of the file and the encoding php assumes are off. That is why you have to take care of the encoding configuration of your setup. A direct question: what character encoding _is_ used in that file? And what character encoding _does_ your php setup use internally? – arkascha Oct 10 '16 at 13:54
  • Consider including an example file and the relevant configuration in the question. – Андрей Беньковский Oct 10 '16 at 15:47

1 Answers1

0

Use PHP office library...

I think this will help you sort this problem : How can I output a UTF-8 CSV in PHP that Excel will read properly?

Community
  • 1
  • 1
Sumesh S
  • 758
  • 5
  • 11