Jump to content

Unicode csv to mysql


phpnewbie112

Recommended Posts

Hello, I have a small piece of code that successfuly insert any imported csv or txt (comma delimited) file into the mysql db but unicode characters are simply returning an empty field. pls advice how can I allow unicode chars too to be imported.

 

after uploading the file

     include "inc/MySql.php";
     $decode = utf8_decode("$target");
     $handle = fopen($decode, "r");
     while (($data = fgetcsv($handle, 10000, ",")) !== FALSE)
     {
     $result = mysql_query($sql) or die(mysql_error());
     $import="INSERT into Table(x,y,z) values('$data[0]','$data[1]','$data[2]')";
      mysql_query($import) or die(mysql_error());
      }

Link to comment
https://forums.phpfreaks.com/topic/122829-unicode-csv-to-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.