468,249 Members | 1,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

text file displaying on screen

I have a file that downloaded a CSV file for the user based upon some
information gathered from the Database. My file was working fine until
recently (I believe that my hosting company did something when they
upgraded to PHP5). Everytime a user tries to download the file, it
displays the contents on the screen. Here is what I have for my file
handling. Am I missing anything obvious?

when called, $filecontent is displayed to the screen...

$downloadfile=$shownic."AttendeeRoster".time().".c sv";
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-type: text/css; charset=UTF-8");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($filecontent));
header("Pragma: no-cache");
header("Expires: 0");
echo $filecontent;

Any help is greatly appreciated.

~Brad

Apr 26 '06 #1
4 1517
Update. The log shows:

[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 333
[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 334
[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 335
[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 336
[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 337
[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 338
The first header line is 333
The last header line is 338

Apr 26 '06 #2
Rik
Brad wrote:
[Wed Apr 26 14:03:25 2006] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/easyshow/public_html/includes/showdb.inc:52) in
/home/easyshow/public_html/adminusersstatsdownload.php on line 333


Somewhere in the code data is sent to the user (even a space or blankline is
data), presumably at
/home/easyshow/public_html/includes/showdb.inc:52. Fix this and headers
will work again.

Grtz,
--
Rik Wasmus
Apr 26 '06 #3
Rik,

Thanks, I have been seeing where there were extra links before the
<?php in the file, but I had extra lines after the ?> in the include
files.

Thanks for you help. I appreciate it.

~Brad

Apr 26 '06 #4
Brad said the following on 26/04/2006 20:10:
I have a file that downloaded a CSV file for the user based upon some
information gathered from the Database. My file was working fine until
recently (I believe that my hosting company did something when they
upgraded to PHP5). Everytime a user tries to download the file, it
displays the contents on the screen. Here is what I have for my file
handling. Am I missing anything obvious?

when called, $filecontent is displayed to the screen...

$downloadfile=$shownic."AttendeeRoster".time().".c sv";
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-type: text/css; charset=UTF-8");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($filecontent));
header("Pragma: no-cache");
header("Expires: 0");
echo $filecontent;


Are you sure you don't want "text/csv", rather than "text/css"??
--
Oli
Apr 26 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by norwich | last post: by
14 posts views Thread by SD | last post: by
reply views Thread by Earl Teigrob | last post: by
5 posts views Thread by Amjad Farran | last post: by
3 posts views Thread by Leonardo da Vinci | last post: by
3 posts views Thread by =?Utf-8?B?SlIx?= | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.