/    Sign up×
Community /Pin to ProfileBookmark

The problems keep coming…

Everytime I think that I am home free I run into another problem. I have the following code to save a table from my database to an excel/csv file. This worked fine for a while but then all of a sudden it has stopped. I am not sure what change that I made recently has made it not work.

[code=php]
<?php

// start session
session_start();
if (!$_SESSION[‘auth’] >= 1) {
// check if authentication was performed
// else die with error
die (“ERROR: Unauthorized access!”);
}
else
{

// Outputting a CSV
header(‘Content-type: text/csv’);
header(‘Content-Disposition: attachment; filename=”goodlink_data.csv”‘);

// Main

$connection = mysql_connect(‘localhost’, ‘CapitalC’, ‘waterloo’) or die (“Connection could not be made.”);

mysql_select_db(‘goodlink’) or die (“Could not connect to database.”);

$query = “SELECT * FROM `license_data` “;

if ($_SESSION[‘user’] != “”)
{
$query .= ” WHERE `entry_date` = ‘”.$_SESSION[‘date’].”‘”;
}

if ($_SESSION[‘user’] != “all” && $_SESSION[‘user’] != “”)
{
$query .= ” and `entered_by` = ‘”.$_SESSION[‘user’].”‘”;
}

$result = mysql_query ($query) or die (“Error in query: $query. “.mysql_error());

echo “Subscriber ID,Company/Customer Name,Customer Address Line 1,Customer Address Line 2,Customer City,Customer Province,Customer Postal Code,User Name,Product Identifier,End Customer Extended Price,Customer Billing Account Number,Mobile Number,ESN,Date,Bill Cycle Date,Market,Entry Date,Entry Time,Entered By,Record IDn”;

while($row = mysql_fetch_row($result))
{
foreach ($row as $value)
{
echo “$value,”;
}
echo “n”;
}

}

?>[/code]

My excel error is attached below:

[upl-file uuid=d73e42a2-8711-4ab3-b1d4-ba49ca775fd1 size=23kB]excel_error.JPG[/upl-file]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ScleppelJul 08.2005 — That's not a PHP error. I think that error means when you downloaded the CVS file it put it in the tempory internet files folder, and it has now been deleted. You should always make sure you download files to a folder that won't have it's contents automatically deleted.

EDIT: Or did you rename or move the file? Try doing a search for it if you think you moved it.
Copy linkTweet thisAlerts:
@SpectreReturnsJul 08.2005 — You probably cleaned your internet cache.
Copy linkTweet thisAlerts:
@CapitalCauthorJul 08.2005 — Yes I did clean my cache... but what does that matter? It should be making a new file anyway... shouldn't it?
Copy linkTweet thisAlerts:
@ScleppelJul 08.2005 — You downloaded the file and it saved into your cache. Your cache was deleted and so was the file. Save your files into "My Documents" or somewhere like that and they won't get deleted.
Copy linkTweet thisAlerts:
@CapitalCauthorJul 11.2005 — Ok that works thanks. Is there a way to disable the open function when downloading a file? Since it may not always work when the user of my site clicks open I would like to make it so that they have to save the file.
×

Success!

Help @CapitalC 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.19,
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,
)...