ok, I have my mp3 upload script working just fine, putting it in the right folder, renaming properly, everything is fine.

Now what I need to know, I want the playlist.xml file to be automatically updated everytime the member uploads a new mp3, is there a way I can do this inside my upload script?, or would it be best to have the data pulled from the DB and put into the xml. I probably need a bit of a push to get started on which one you think is the best option. I'm still learning this fun stuff

    oh, and the members will be able to upload a max of 10 mp3s, so of course the xml file wuld need to fill in the appropriate data inside at least 10 song tags

      My inclination is to store all the data in the DB, as that is probably the thing that is best for storing data. If you need an XML file for some reason, it should be for data exchange, as opposed to storage, and therefore could be generated dynamically via a PHP script upon request. (You could implement any of several caching mechanisms so that you don't have to query the DB every time the XML file is requested.)

        the xml file is to be loaded into an mp3 player, so I'm ok with the info for the xml to be stored on the DB and just be called whenever the player is initialized. My problem is, I have tried 3 different DOM scripts, and I can't get any of them working, of course I modified them to suit my setup, but I just couldn't get them to work, another thing, since I am relatively new to all of this, do I insert the xml writing script inside the parsing for the mp3 upload, or do I put it somewhere else in the php code.

        and one last thing, in the DB for the mp3 upload, the table has these rows, mp3_id(int, auto increment, primary), username, mp3_title, mp3_url, mp3_date.

        now obviously the date doesn't need to be shown in the flash player, but my question is, how do I handle the auto increment of the mp3_id, can I make it member specific?, cause my concern is, lets say John uploads 5 mp3 files on his page, they'll be numbered 1-5, then tom uploads 3 mp3 files on his page, they'll be numbered 6-8 and so on, so how would I reflect this for each member in their own xml file. each one will be under their username in the db, but I just don't know how to output the increment values for each xml.

          Normally, you should not care what the actual value is of such an auto-incremented ID: its only purpose is to be a unique identifier for that DB row. In this case, presumably all you'd care about is the user_id (or user_name, or whatever is used to uniquely associate that row with a user). Then, assuming you know which user is requesting his/her playlist (e.g. via your site login mechanism), you would query the DB for all rows where the user_id matches that logged in user's ID.

          $query = "SELECT * FROM playlists WHERE user_id=" . $sanitizedUserId;
          

            Hey twinrecords,

            I had a similar problem a few years ago but got round it by setting the playlist as a PHP file, but that outputs XML.

            For example, set the link to your playlist as playlist.php?user=user&..., then in your playlist.php file do something like so:

            header("Content-Type:text/xml");
            echo '<?xml version="1.0" encoding="UTF-8" ?>
            <songs>';
            $query = "query here";
            $result = mysql_query($query);
            while ($row=mysql_fetch_assoc($result)) {
                echo '<song>...</song>';
            }
            echo '</songs>';

            Not sure if that's of any help but it worked for me when I needed to load a dynamic playlist into a flash MP3 player.

            Cheers

            EDIT: btw, if your MP3 player only accepts a playlist with a .xml filetype you can add the following rule to your .htaccess:

            Redirect /folder/playlist.xml http://www.mywebsite.com/folder/playlist.php

              Write a Reply...