mysql插入fgetcsv - PHP中的土耳其字符问题

时间:2015-02-20 16:46:47

标签: php mysql csv fgetcsv

将CSV文件插入MySQL表时遇到问题

Collation = latin5_turkish_ci (also tried utf8_general_ci)

我确定csv文件UTF-8(从Notepad ++检查)尝试使用BOM并且没有BOM也尝试setlocale 这是我的代码

if ($_FILES[csv][size] > 0) {

// get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");

// loop through the csv file and insert into database
do {
    if ($data[0]) {
        mysql_query("INSERT INTO contact (contact_first, contact_last) VALUES
            (
                '".addslashes($data[0])."',
                '".addslashes($data[1])."'
            )
        ");
    }
} while ($data = fgetcsv($handle,1000,",","'"));

输出

kelbaÅ? hüseyin

我需要什么

kelbaş hüseyin

感谢您的回答

0 个答案:

没有答案