title: header('Content-type: application/octet-stream') cause 0 byte files
body: <p>I'm using database query in PHP to retrieve a binary file. But when I'm trying to force download it, the header('Content-type:  application/octet-stream') line cause 0 byte files. Without that line I can download the file with full content. It's a binary file that's for sure so I just can't understand why that line causes the problem.
  The code:</p>
  
  <pre><code>$result = mysql_query("SELECT data FROM stored_file WHERE file_name = '$q'");
  
  while($row = mysql_fetch_array($result))
  {
      $file = $row['data'];
  }
  
  
      header('Content-disposition: attachment; filename='.$q);
      header('Content-type: application/octet-stream');
      header('Content-Length: '.filesize($file));
      header("Pragma: no-cache");
      header("Expires: 0");
      echo $file;
  </code></pre>
  
  <p>Any idea? Thanks.</p>