phpmady Posted April 17, 2011 Share Posted April 17, 2011 hi, I want to download the file, where i have the search query in session variable, in my local system its working good, but in server its not working, any guidance please <?php include("global.php"); // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function cleanData(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } $sql = $_SESSION['emp_search_sql']; // file name for download $filename = "employees_" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel; charset=UTF-8"); header("Pragma: no-cache"); $flag = false; $result = $DB_site->query($sql) or die('Query failed!'); while(false !== ($row = mysql_fetch_assoc($result))) { if(!$flag) { // display field/column names as first row echo implode("\t", array_keys($row)) . "\n"; $flag = true; } array_walk($row, 'cleanData'); echo implode("\t", array_values($row)) . "\n"; } ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/233981-file-download-problem-in-server/ Share on other sites More sharing options...
tobimichigan Posted April 17, 2011 Share Posted April 17, 2011 It seems as if you're only showing part of your code..nonetheless if its working locally, why don't you check your variable connections if it matches the remote angle? Quote Link to comment https://forums.phpfreaks.com/topic/233981-file-download-problem-in-server/#findComment-1202641 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.