Download.php not working..
i was just making a download.php file which accepts the song_id from the url and fetch it from database..
example:
download.php?id=111
this will download the song with id=111 from the database..
but the song is not being downloaded..
no response just blank screen.
the details i am having are
table:
id int(11) not null auto increment
physicalpath varchar(250) not null
FileName varchar(250)
download.php:contents
<?php
if ($id) {
include "open_db.inc";
$sql = "SELECT DownloadFile, OriginalFileName FROM songs WHERE id=$id";
$result = @mysql_query($sql, $db);
$path = @mysql_result($result, 0, "DownloadFile");
$name = @mysql_result($result, 0, "OriginalFileName");
header("Content-type: audio/mpeg");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
echo $path;
}
?>
the open_db.inc: contents
<?php
$db = mysql_connect("localhost", "DB_USER", "DB_PASSWORD");
mysql_select_db("DB_NAME", $db) or die(mysql_errno() . ": " . mysql_error() . "<br>");
?>
i was just making a download.php file which accepts the song_id from the url and fetch it from database..
example:
download.php?id=111
this will download the song with id=111 from the database..
but the song is not being downloaded..
no response just blank screen.
the details i am having are
table:
id int(11) not null auto increment
physicalpath varchar(250) not null
FileName varchar(250)
download.php:contents
<?php
if ($id) {
include "open_db.inc";
$sql = "SELECT DownloadFile, OriginalFileName FROM songs WHERE id=$id";
$result = @mysql_query($sql, $db);
$path = @mysql_result($result, 0, "DownloadFile");
$name = @mysql_result($result, 0, "OriginalFileName");
header("Content-type: audio/mpeg");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
echo $path;
}
?>
the open_db.inc: contents
<?php
$db = mysql_connect("localhost", "DB_USER", "DB_PASSWORD");
mysql_select_db("DB_NAME", $db) or die(mysql_errno() . ": " . mysql_error() . "<br>");
?>
Comment