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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)