Header Problems
| From: | David Smith | Date: | Wed, 13 Dec 2000 00:07:27 +0000 |
| Subject: | Header Problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-29985@lists.php.net to get a copy of this message | ||
Below is my code, download.php, used to count the number of times one
downloads the file then redirects them to the zip file. The problem is I
keep getting that awful error about the headers all ready been created,
there is no header info in the script. I have tried several JavaScript code
and meta tag refreshing to complete the task but those leave a blank white
page in the background once a user requests the file. When my site was in
ASP I made this to open in a new window then once the zip download box
opened the new window disappeared only I can't get this to happen in PHP. I
am sure that it will if this header function would work properly. Any
sugestions?
David Smith
http://www.combatfs.com
<?php
$connection = mysql_connect ("localhost", "combat", "******");
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
$query = "select * from warbirds_db WHERE FileID ='$FileID'";
$result = mysql_db_query ("combat", $query);
if ($result){
$numOfRows = mysql_num_rows ($result);
for ($i = 0; $i < $numOfRows; $i++){
$FileID = mysql_result ($result, $i, "FileID");
$FileType = mysql_result ($result, $i, "FileType");
$FileURL = mysql_result ($result, $i, "FileURL");
$FileCount = mysql_result ($result, $i, "FileCount");
}
$Count = ($FileCount + 1);
$update_query = "UPDATE warbirds_db SET FileCount = '$Count' WHERE FileID =
'$FileID'";
$update_result = mysql_db_query ("combat", $update_query);
header ("Location: http://www.combatfs.com/ftp/$FileType/$FileURL");
}
else{
echo mysql_errno().": ".mysql_error()."<BR>";
}
mysql_close ();
?>