Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于导入带有阿拉伯语内容的CSV的Php脚本_Php_Mysql_Csv_Import_Arabic - Fatal编程技术网

用于导入带有阿拉伯语内容的CSV的Php脚本

用于导入带有阿拉伯语内容的CSV的Php脚本,php,mysql,csv,import,arabic,Php,Mysql,Csv,Import,Arabic,我必须构建一个脚本来导入一个CSV文件,在一个Column中包含阿拉伯语内容 我一直在网上搜索,并设法将我的CSV文件转换为UTF8 $filename = $_FILES["csv"]["tmp_name"]; $file = fopen($filename, "r"); $count = 0; while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { $count++; if($count>1){ // tried

我必须构建一个脚本来导入一个CSV文件,在一个Column中包含阿拉伯语内容

我一直在网上搜索,并设法将我的CSV文件转换为UTF8

$filename = $_FILES["csv"]["tmp_name"];

$file = fopen($filename, "r");

$count = 0;
while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
{
$count++;
if($count>1){

// tried to convert using below
$string_decoded =  iconv("windows-1256", "utf-8", $emapData[2]);
// convert code above

$sql = "INSERT into `$table` (SurahNo,AyatNo,Ayat) values ('$emapData[0]','$emapData[1]','$string_decoded')";
echo $sql;
mysql_query($sql);  
}
}
我尝试使用iconv进行转换,但仍然在mysql中导入垃圾内容

导入的内容如下所示 ط¨ظگط³ظ’呲呲呲呲呲呲呲呲呲呲呲呲呲

如果您愿意,可以共享我的CSV文件


需要帮助,请花费数小时进行搜索。

您的mysql表支持utf8?是的,这是我的数据库,看起来像是创建表如果不存在halar_表SurahNo int11 NOT NULL,AyatNo int11 NOT NULL,Ayat varchar1000字符集utf8mb4 COLLATE utf8mb4_bin NOT NULL ENGINE=InnoDB DEFAULT CHARSET=latin1;回显的sql是否正确显示,或者是否也出现了错误?我认为您需要设置连接字符集。我还建议在数据库操作中使用mysqli或PDO。请参阅:和echo也显示错误。这就是echo插入halar_表SurahNo、AyatNo、Ayat值“1”、“1”、“1”时显示的内容™Ø¸â€¦Ø¸Ú¯ ط§ظ„ظ„ظ‘ظژظ‡ظگ ط§ظ„ط±ظ‘ظژط­ظ’ظ…ظژظ°ظ†ظگ ط§ظ„ط±ظ‘ظژط­ظگظٹظ…ظگ'