Page 1 of 1

download problem

Posted: Wed Jun 01, 2005 3:03 pm
by Think Pink
hello, pls help with the following
i have a page that exports records from a table in a csv format
everything works fine, but if i want to restrict acces to that page, then in Internet expplorer i get an error message "Internet explorer cannot download file_to_download.php from http://www.blabla.com". In netscape works fine.

here is a piece of my code

file_to_download.php

Code: Select all

include ("authentification.php");
include ("connection_to_db.php");
if(!authorized()){
echo "not authorized";
}
else{
header("Content-type: application/vnd.ms-excel");
header("Content-disposition:  attachment; filename=".date("Y-m-d").".csv");
$sql = "SELECT * FROM table ORDER BY name ASC";
$result = mysql_query($sql);

@$number = mysql_num_rows($result);
echo "Id,Name";
 for($i=0; $i<$number; $i++){
      $id = mysql_result($result, $i, "id");
      $name = mysql_result($result, $i, "name");
   echo "$id,$name\r\n";
 }
}
apparently the problem seems to be session_start() from authentification.php
i tryed to do it without authentification.php and is ok, but if i insert session_start() in file_to_download.php the error message comes again