help..problem..

Started on the old forum in May 2010 · view the original in the archive · old links redirect here

2 replies · 470 views · started 16 years ago · 1 min read

3 participants
jaypatel Newbie · 1 posts #1

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() . " "); ?>
something else Fellow · 2,296 posts #2
<?php
$id = $_GET["id"];
if ($id) {
include "open_db.inc";
$sql = "SELECT physicalpath, FileName FROM songs WHERE id=$id";

$result = @mysql_query($sql, $db);
$path = @mysql_result($result, 0, "physicalpath");
$name = @mysql_result($result, 0, "FileName"); 
header("Content-type: audio/mpeg");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
echo $path;
}
?>

I dont think echo $path is ment to be in there either lol

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close