Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 902223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:40:58+00:00 2026-05-15T15:40:58+00:00

I have a CSV export script (enrdata_arch.php) which calls information from an existing database

  • 0

I have a CSV export script (enrdata_arch.php) which calls information from an existing database and exports it into CSV format. For some reason however, the script returns the following error ONLY in Internet Explorer:

Microsoft Office Excel cannot access the file ‘https://www.domain.com/admin/enrdata_arch.php‘. There are several possible reasons:

  • the filename or path does not exist
  • the file is being used by another program
  • the workbook you are trying to save has the same name as currently open workbook

**

The original script is posted below:

**

<?php

$host = 'localhost';
$user = 'username';
$pass = 'password';
$db = 'db_name';
$table = 'table_name';
$archive = 'archive_name';
$file = 'export';

$link = mysql_connect($host, $user, $pass) or die("Can not connect.".mysql_error());
mysql_select_db($db) or die("Can not connect.");

$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field'].", ";
$i++;
}
}
$csv_output .= "\n";

$values = mysql_query("SELECT * FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= '"'.$rowr[$j].'",'; 
}
$csv_output .= "\n";
}

$filename = $file."_".date("Y-m-d",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;

//transfers old data to archive
$transfer = mysql_query('INSERT INTO '.$archive.' SELECT * FROM '.$table) or die(mysql_error());

//empties existing table
$query = mysql_query('TRUNCATE TABLE '.$table) or die(mysql_error());

mysql_close($link);
exit;
?>

It almost seems as if the script is trying to save and open a PHP file only when using IE. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:40:59+00:00Added an answer on May 15, 2026 at 3:40 pm

    The headings for SSL is a known problem with IE

    I use

    header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
    header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
    header ('Pragma: public'); // HTTP/1.0
    

    and it’s the ‘Pragma: public that’s the key for IE/ssl

    Content type for a CSV file is

    text/csv
    

    or

    text/plain
    

    rather than

    application/vnd.ms-excel
    

    which is specifically MS Excel .xls speardsheets

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that produces a .CSV export file from a MySQL
I'm trying to export data from SQL Server into CSV format. I have a
I have a script to export data from MYSQL to a CSV file. the
Ok, so I have the following script that will export data from my database
I have done a script in PHP to export a MySQL table into a
I have to do an export from DB to CSV. ( .NET 2 )
i have csv files, java app and database, i read csv file from my
i need to export data from a table to a csv. i have the
I have a simple script to get an export from MongoDB: #!/bin/sh -x QUERY='{
I have a export script that export items to a csv file. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.