[PHP-DB] Excel headers not working anymore

2005-02-11 Thread Perry, Matthew (Fire Marshal's Office)
Good morning,

I have been using PHP4.1, Apache, and MySQL for a few years now and have
never had a problem with my Excel headers.  When I want to output html to
Excel I place the following on the top of the page:

?header (Content-type: application/vnd.ms-excel);
header (Content-Disposition: attachment );

After moving to PHP 4.3, MS SQL Server, Windows 2000 Server I am having
problems with this header.  I get the message:
Internet Explorer cannot download myfile.php from myintranet.net

The message does not always appear.  Some of the files download, others do
not.  

I have tried to find the problem with the following methods.  They may shed
some light on this problem:
1) I removed the header to see how the file outputs in HTML.  They output
fine.
2) I used my local server (which runs Apache and PHP4.3) with the same files
and it downloads to excel perfectly!
3) I have compared the files that work with the ones that don't, removed
anything that seems unusual, and replaced sections from the files that
worked.  There still does not seem to be any pattern.  I thought the size of
the file generated would play a roll but it doesn't.  After shrinking the
output to a single character, some files still do not work!

Unfortunately it is more difficult to find support for PHP and Windows 2000
Server.  I have some doubts that the files are not downloading because of
default server security reasons (since some of the files work!).

Does anyone know what might be causing this problem?

- Matthew Perry

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Excel headers not working anymore

2005-02-11 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
Good morning,
I have been using PHP4.1, Apache, and MySQL for a few years now and have
never had a problem with my Excel headers.  When I want to output html to
Excel I place the following on the top of the page:
?header (Content-type: application/vnd.ms-excel);
header (Content-Disposition: attachment );
After moving to PHP 4.3, MS SQL Server, Windows 2000 Server I am having
problems with this header.  I get the message:
Internet Explorer cannot download myfile.php from myintranet.net
1) is your server still configured to recognize ? as php (and only 
php)?  You may want to make that ?php to be more sure.  The headers 
likely aren't being sent if it's prompting to download .php - seems like 
it's not recognizing the extension, perhaps it's disabled for a certain 
pattern.
You could also try changing it to:

header(Content-disposition: attachment; filename=\$filename\);
to ensure that it's going off (set $filename obviously, something 
distinct like my_excel.xls)

2) Are you using ssl and sessions?  You'll find some fun and strange 
behavior trying to save output from an ssl connection and sessions - 
because sessions force no-cache, and (IE in particular) has real issues 
with storing the output of a no-cache'd https - you can't save it 
locally or open with an external application, because either way it has 
to store it somewhere other than memory, which would be caching.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Excel headers not working anymore

2005-02-11 Thread Perry, Matthew (Fire Marshal's Office)
Wow!
Removing the file that controlled the session array fixed the problem
(suggestion 2).

I was using ssl and session data and would never have guessed it would trip
things up.  I would have stared at this problem for weeks and probably not
have solved the problem.

Also I will change my code to include ?php instead of ? from now on just
to be sure.

Thank you very much for your help.
- Matthew Perry


-Original Message-
From: Martin Norland [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 11, 2005 10:47 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Excel headers not working anymore

Perry, Matthew (Fire Marshal's Office) wrote:
 Good morning,
 
 I have been using PHP4.1, Apache, and MySQL for a few years now and have
 never had a problem with my Excel headers.  When I want to output html to
 Excel I place the following on the top of the page:
 
 ?header (Content-type: application/vnd.ms-excel);
 header (Content-Disposition: attachment );
 
 After moving to PHP 4.3, MS SQL Server, Windows 2000 Server I am having
 problems with this header.  I get the message:
 Internet Explorer cannot download myfile.php from myintranet.net

1) is your server still configured to recognize ? as php (and only 
php)?  You may want to make that ?php to be more sure.  The headers 
likely aren't being sent if it's prompting to download .php - seems like 
it's not recognizing the extension, perhaps it's disabled for a certain 
pattern.
You could also try changing it to:

header(Content-disposition: attachment; filename=\$filename\);

to ensure that it's going off (set $filename obviously, something 
distinct like my_excel.xls)


2) Are you using ssl and sessions?  You'll find some fun and strange 
behavior trying to save output from an ssl connection and sessions - 
because sessions force no-cache, and (IE in particular) has real issues 
with storing the output of a no-cache'd https - you can't save it 
locally or open with an external application, because either way it has 
to store it somewhere other than memory, which would be caching.

Cheers,
-- 
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Excel headers not working anymore

2005-02-11 Thread Martin Norland
Perry, Matthew (Fire Marshal's Office) wrote:
Wow!
Removing the file that controlled the session array fixed the problem
(suggestion 2).
I was using ssl and session data and would never have guessed it would trip
things up.  I would have stared at this problem for weeks and probably not
have solved the problem.
Also I will change my code to include ?php instead of ? from now on just
to be sure.
Thank you very much for your help.
- Matthew Perry
The following is what I use - it allows caching but forces it not to be 
cached (it's a report, so it's changing every time).  It's a little 
redundant, because these items are a little bit of a pain to follow.  I 
have these running before the session is set - you may only need the 
session_cache_limiter call, come to think, since I'm setting these 
before the session starts and the others likely get overwritten.

?php
header('Cache-Control: private, must-revalidate');
header('Pragma: private'); // allow private caching
header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT); // set to 
be modified 'now'
session_cache_limiter(private, must-revalidate); // allow private 
caching, but cache MUST check output
// rest of script
?

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php