/    Sign up×
Community /Pin to ProfileBookmark

Export To Excel from the database problem in server

Hi,
i have a problem export to excel sheet…
in the local system it is working but when it comes to server it is not working…
as i need to change any settings or anything else?… please get me the ans…

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscJun 16.2010 — We'll get you the 'ans', if you tell us what your problem is. What relevant code are you using? What errors are you getting? Basically, what in the world are you talking about?
Copy linkTweet thisAlerts:
@ravichegantiauthorJun 19.2010 — We'll get you the 'ans', if you tell us what your problem is. What relevant code are you using? What errors are you getting? Basically, what in the world are you talking about?[/QUOTE]
my problem is when i run the script it is working in the local system i,e it is showing the details in excel but when i run this script in the server means when i upload the file in to server and run it displaying the output in the page but not in the excel sheet...

here is my code...

<?php

include "db.php";

$connection = mysql_connect($host, $username, $pwd) or die ("could't connect to mysql");

$db = mysql_select_db($database, $connection) or die("Couldn't select database.");

$sql = "Select * from $table";
$result = @mysql_query($sql) or die("Couldn't execute query:".mysql_error().''.mysql_errno());

header('Content-Type: application/vnd.ms-excel'); //define header info for browser
header('Content-Disposition: attachment; filename='.$table.'-'.date('Ymd').'.xls');
header('Pragma: no-cache');
header('Expires: 0');

for ($i = 0; $i < mysql_num_fields($result); $i++) // show column names as names of MySQL fields
echo mysql_field_name($result, $i)."t";
print("n");

while($row = mysql_fetch_row($result))
{
//set_time_limit(60); // you can enable this if you have lot of data
$output = '';
for($j=0; $j < mysql_num_fields($result); $j++)
{
if(!isset($row[$j]))
$output .= "NULLt";

else
$output .= "$row[$j]t";

}
$output = preg_replace("/rn|nr|n|r/", ' ', $output);

print(trim($output))."tn";
}


?>
×

Success!

Help @ravicheganti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...