Mysql データベースからの情報を含む CSV ファイルをエクスポートするスクリプトを作成しました。このスクリプトは、Linux サーバー (Apache) では問題なく動作しますが、Windows サーバー (Apache) では動作しません。
問題はこのヘッダーにあると思います!!!
header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename=iBlock_download.csv');
header('Pragma: no-cache');
header("Content-Type: text/html; charset=UTF-8");
ここで誰か助けてくれませんか?
ありがとう
スクリプトは次のとおりです。
header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename=iBlock_download.csv');
header('Pragma: no-cache');
header("Content-Type: text/html; charset=UTF-8");
include('./lib/sqlString.php');
$_id=$_GET['_id'];
$ResultPointer = mysql_query("SELECT * FROM projekte where pro_id='$_id'");
for($i = 0, $Export = ""; $i < mysql_num_rows($ResultPointer); $i++)
{
$Daten = mysql_fetch_object($ResultPointer);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_id);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_desc);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_exp);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_animal_nr);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_organ);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_treatment);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_comment);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_genotype);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_start_date);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_aktion);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_txt1);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_aktion);
$Spalte[] = str_replace("\"", "\"\"", $Daten->pro_user_name);
$ResultPointer2 = mysql_query("SELECT * FROM pro where fn_pro_id ='$Daten->pro_id'");
$sume=mysql_num_rows($ResultPointer2);
for($i = 0, $Export = ""; $i < mysql_num_rows($ResultPointer2); $i++)
{
$sume=mysql_num_rows($ResultPointer2);
$Daten2 = mysql_fetch_object($ResultPointer2);
$Spalte[] = str_replace("\"", "\"\"", $Daten2->fn_desc);
$Spalte[] = str_replace("\"", "\"\"", $Daten2->fn_order_date);
}
for($j = 0; $j < count($Spalte); $j++)
{
$Export .= "\"" . $Spalte[$j] . "\"";
if($j != count($Spalte)-1)
{
$Export .= ";";
}
}
$Export .= "\r\n";
$Spalte = "";
}
echo $Export;