RE: [PHP] creating a file to be downloaded by user

From: Date: Tue, 31 Dec 2002 16:58:24 +0000
Subject: RE: [PHP] creating a file to be downloaded by user
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148569@lists.php.net to get a copy of this message
If you alter the output-buffering setting in php.ini to On , it should work. -----Oorspronkelijk bericht----- Van: Amanda McComb [mailto:amccomb@indiana.edu] Verzonden: Thursday, May 22, 2003 5:38 PM Aan: php-general@lists.php.net Onderwerp: [PHP] creating a file to be downloaded by user I am trying to create a file for a user to download. I am having trouble and I am getting an error about headers (which I admit I don't really understand). Here is the error I get: Warning: Cannot add header information - headers already sent by (output started at /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/database.php:2) in /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/download.php on line 41 Warning: Cannot add header information - headers already sent by (output started at /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/database.php:2) in /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/download.php on line 42 Warning: Cannot add header information - headers already sent by (output started at /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/database.php:2) in /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/download.php on line 43 Warning: Cannot add header information - headers already sent by (output started at /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/database.php:2) in /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/download.php on line 44 Warning: Cannot add header information - headers already sent by (output started at /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/database.php:2) in /usr/local/packages/apache-1.3.27/htdocs/amccomb/prodev/download.php on line 45 First Name Last Name test test test test test test test test test test test test dfg dfgffhf dfg dfgffhf dfg dfgffhf And here is my code: <? include("database.php"); if ($start_date and $end_date){ $count_query = "SELECT count(*) FROM customer_t"; $count_query .= " WHERE date_entered BETWEEN '"; $count_query .= $start_date; $count_query .= "' and '"; $count_query .= $end_date; $count_query .= "' ORDER BY date_entered"; $num_results = mysql_query($count_query) or die("Customer Count Failed!"); $num_result = mysql_fetch_array($num_results); if ($num_result[0]== 0){ ?><font color=red>No Results for the date range entered.</font><? }else{ $sql = "SELECT first_name, last_name FROM customer_t "; $sql .= "WHERE date_entered BETWEEN '$start_date' and '$end_date'"; $query = mysql_query($sql); if (!$query) { echo('Error'); } else { $content = "First Name\tLast Name\n"; while (list($first_name, $last_name)=mysql_fetch_row($query)) { $content = $content."$first_name\t$last_name\n"; } } header("Content-type: application/vnd.ms-excel"); header("Content-disposition: inline; filename=test_schedule.xls"); header("Content-Length: " . strlen($content)); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); echo("$content"); } } ?> What am I doing wrong? Is there a better way to allow a user to download a file? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#148569) next »