phpnewbie112 Posted September 5, 2008 Share Posted September 5, 2008 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 More sharing options...
discomatt Posted September 5, 2008 Share Posted September 5, 2008 Is your SQL table's enctype unicode/UTF? Link to comment https://forums.phpfreaks.com/topic/122829-unicode-csv-to-mysql/#findComment-634313 Share on other sites More sharing options...
phpnewbie112 Posted September 5, 2008 Author Share Posted September 5, 2008 collation is utf8_bin Link to comment https://forums.phpfreaks.com/topic/122829-unicode-csv-to-mysql/#findComment-634318 Share on other sites More sharing options...
Mchl Posted September 5, 2008 Share Posted September 5, 2008 What about charset? You can also use LOAD DATA INFILE to load CSV files much faster than by parsing them with php. Link to comment https://forums.phpfreaks.com/topic/122829-unicode-csv-to-mysql/#findComment-634424 Share on other sites More sharing options...
phpnewbie112 Posted September 6, 2008 Author Share Posted September 6, 2008 charset is also utf-8 Link to comment https://forums.phpfreaks.com/topic/122829-unicode-csv-to-mysql/#findComment-635060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.