SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php script for download error

    Tyring to get a flash button to download a mp3 from my site.

    My flash actionscript points to the php file in the folder of the mp3
    like this:
    on (press) {
    getURL("http://www.dieskim.com/mp3/Dans!_radiomix.php");
    }

    but my browser displays the php code only ----see:
    http://www.dieskim.com/mp3/Dans!_radiomix.php

    have I missed something then?

    this is the php I used:

    //get the filename from database
    //.....

    header("Content-Type: application/download");
    header("Content-Disposition: attachment; $Dans!_radiomix.mp3");
    header("Content-Length: ".filesize($Dans!_radiomix.mp3));
    readfile($Dans!_radiomix.mp3);

    Pls help thanks!!!

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    is that parsed as php and inside <?php ?> tags?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    oh and the ! in the filename wont help.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, no I added the <? TAGS now.....it gives me this error below
    <?php

    //get the filename from database
    //.....

    header("Content-Type: application/download");
    header("Content-Disposition: attachment; $Dans!_radiomix.mp3");
    header("Content-Length: ".filesize($Dans!_radiomix.mp3"));
    readfile($Dans!_radiomix.mp3);
    ?>


    Parse error: parse error, unexpected '!' in /hsphere/local/home/dieskim/dieskim.com/mp3/Dans!_radiomix.php on line 8

    what does parsed mean?

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Parsed means that the script has been read by the php interpretter and then served to the browser.
    The problem is indeed the ! in the filename.

    You can either manually remove the ! or use str_replace("!", "", $YourVariableGoesHere);

    or put the variable into double quotes "$Dans!_radiomix.mp3" so it is read as a litteral string (personally, get rid of the ! from the name!)
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, will try that....waiting for my upload to the site to update....to see if it worked.
    will get back to you if it doesn't
    :-))

  7. #7
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, the following error displayed in my browser:


    Parse error: parse error, unexpected '\"' in /hsphere/local/home/dieskim/dieskim.com/mp3/Dans_radiomix.php on line 8

    any idea what the problem might be?

  8. #8
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Post the page code as you have it now
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  9. #9
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php:

    <?php

    //get the filename from database
    //.....

    header("Content-Type: application/download");
    header("Content-Disposition: attachment; $Dans_radiomix.mp3");
    header("Content-Length: ".filesize($Dans_radiomix.mp3"));
    readfile($Dans_radiomix.mp3);
    ?>


    flash:
    on (press) {
    getURL("http://www.dieskim.com/mp3/Dans_radiomix.php");
    }

    php and mp3 files reside on my site in a folder called mp3.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •