title: PHP - Exporting CSV Files
body: <p>I have written a script, which exports a CSV file with informations from Mysql databse. This script is working without problem under Linux Server(Apache) but it dosen't work under Windows Server(Apache). </p>
  
  <p>I think the Problem is here with this headers!!!</p>
  
  <pre class="lang-php prettyprint-override"><code>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");
  </code></pre>
  
  <p>Can anyone here help?</p>
  
  <p>Thanks</p>
  
  <p>The Script is here:</p>
  
  <pre><code>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 &lt; mysql_num_rows($ResultPointer); $i++)
  {
  
  $Daten = mysql_fetch_object($ResultPointer);
  
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_id);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_desc);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_exp);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_animal_nr);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_organ);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_treatment);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_comment);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_genotype);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_start_date);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_aktion);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_txt1);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_aktion);
  $Spalte[] = str_replace("\"", "\"\"", $Daten-&gt;pro_user_name);
  
  $ResultPointer2 = mysql_query("SELECT * FROM pro where fn_pro_id ='$Daten-&gt;pro_id'");
  $sume=mysql_num_rows($ResultPointer2);
  
  for($i = 0, $Export = ""; $i &lt; mysql_num_rows($ResultPointer2); $i++)
  {
  $sume=mysql_num_rows($ResultPointer2);
  
  $Daten2 = mysql_fetch_object($ResultPointer2);
  $Spalte[] = str_replace("\"", "\"\"", $Daten2-&gt;fn_desc);
  $Spalte[] = str_replace("\"", "\"\"", $Daten2-&gt;fn_order_date);
  
      }
  
  for($j = 0; $j &lt; count($Spalte); $j++)
  {
  $Export .= "\"" . $Spalte[$j] . "\"";
  if($j != count($Spalte)-1)
  {
  $Export .= ";";
  }
  }
  $Export .= "\r\n";
  $Spalte = "";
  }
  echo $Export;
  </code></pre>