Hi folks.
So, I am in the same situation as Roy_lit, where I am generating a KML file from a SQL query with PHP. I also was generating an excel csv and getting similar error messages. (So, no, I wasn't having trouble with the kml files on this bbs).
Disabling sessions fixed the problem, as Roy_lit said it would. Unfortunately, my application depends on sessions, so this is not a viable solution.
A bit more sleuthing and reading
this page led me to another solution: turn off the caching headers in php. This is done (in php 5) via the session.cache_limiter property in php.ini. Mine was set to nocache, but when I deleted that value, I had no problems with downloading KML files with Internet Explorer.
Thanks everyone for the suggestions and help.
Dan