help..problem..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    help..problem..

    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>");
    ?>

    #2
    PHP Code:
    <?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($result0"physicalpath");
    $name = @mysql_result($result0"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
    Last edited by something else; 28.05.10, 12:47.

    Comment


      #3
      it shud be readfile

      Comment

      Working...
      X