dongqi8863 2019-05-21 05:53
浏览 65

将MYSQL数据表从网站导出为CSV时出现错误的字符

I found solutions here but still got problems. I have data table in my website which one uses Georgian Fonts, in my MYSQL database those fonts are displayed normally but when I try to download this table using export.php in my PC with .csv file the fonts are like

გáƒáƒ¡áƒáƒ¡áƒ•áƒšáƒ”ლში

In my export.php the code is below:

if(isset($_POST["export"]))  
 {   
      header('Content-Transfer-Encoding: binary'); 
      header('Content-Type: text/csv; charset=UTF-8');  
      header('Content-Disposition: attachment; filename=data.csv');  
      $output = fopen("php://output", "w");  
      fputcsv($output, array('არდუინოს N','ტრანზაქცია', 'User ID', 'Transaction Date', 'Object Name', 'Terminal Name', 'Amount'));  
      $query = "SELECT * FROM Table WHERE userID='$userID' ORDER BY trID DESC"; 
      $result = mysqli_query($db, $query);  
      while($row = mysqli_fetch_assoc($result))  
      {  
           fputcsv($output, $row);  
      }  
      fclose($output);  
 }  

Download works fine I got file data.csv but inside this file characters are unrecognized Link for Image

Any ideas? What is wrong ? If you think that is duplicated Question then I can tell you NO because before posting here I found lots of same solutions but nothing helps In my database connection php file I have added

$db->set_charset("utf8");

and

mysqli_query("SET NAMES 'utf8';");

But nothing changed... Any tips what would cause this problem would be great, Thank you guys in advance...

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题
    • ¥15 Python时间序列如何拟合疏系数模型
    • ¥15 求学软件的前人们指明方向🥺
    • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题