Here's the code I got from a tutorial, which I edited for local testing:
===================================================
<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include "dbcon/dbcon.php";
mysql_select_db($db_name, $mydb);
$query = "SELECT `id`, `name` FROM `upload` WHERE `UName` = '".$uname."'";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "You have no uploaded files <br>";
}
else
{
while(list($id, $name) = mysql_fetch_array($result))
{
echo "<a href='download.php?id=".$id."'>".$name."</a></br>";
}
}
include "dbcon/closedb.php";
?>
</body>
</html>
<?php
if(isset($_GET['id']))
{
include "dbcon/dbcon.php";
mysql_select_db($db_name, $mydb);
$id = $_GET['id'];
$query = "SELECT `name`, `type`, `size`, `path` FROM `upload` WHERE `id` = '".$id."'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $filePath) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
readfile($filePath);
include "dbcon/closedb.php";
exit;
}
?>
============================================================
this is a download script. It gives me a warning that says:
Warning: Cannot modify header information - headers already sent by (output started at /www/99k.org/c/l/a/clarenceprojex/htdocs/download.php:24) in /www/99k.org/c/l/a/clarenceprojex/htdocs/download.php on line 40
Warning: Cannot modify header information - headers already sent by (output started at /www/99k.org/c/l/a/clarenceprojex/htdocs/download.php:24) in /www/99k.org/c/l/a/clarenceprojex/htdocs/download.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at /www/99k.org/c/l/a/clarenceprojex/htdocs/download.php:24) in /www/99k.org/c/l/a/clarenceprojex/htdocs/download.php on line 42
============================================================
Is there anyway I can make this work without removing the echo for the download link(s)?
Or is there a work around for this?
Thanks in advance!