We help IT Professionals succeed at work.

Jukebox that grabs from a PHP file

Bruce Gust
Bruce Gust asked
Medium Priority
Last Modified: 2013-12-12
I need to build an interface that allows a user to upload an mp3 file and then be able to view their uploaded song through a Flash based jukebox.

Right now, I've got most of the "pieces" to this puzzle assembled and / or figured out. I've got a Flash Jukebox grabbing mp3 files from an XML file that I'm writing using PHP. It works great, but the problem is that I want to somehow pass a variable to this PHP / XML page that dictates from where in the database it's getting its info and I can't figure it out.

Right now, they click on a link and it goes to this Jukebox that's reading from songInfo.php. The php page will grab from the database the appropriate song titles, but how am I going go pull that off?

If the link to the Jukebox is jukebox.php, how do I embed in that link info that can then be passed on to songInfo.php? I want jukebox.php to be nothing more than a jukebox. In other words, I want the link to the Jukebox to be jukebox.php?id=4 and then the id is somehow passed to the songInfo.php file where it's drawing the song info from the database based on the id which is "4." That's what I want to do. How?
Watch Question

I am not quite sure I understand the question completely but if you want a variable to be available to other PHP scripts you could use SESSION variables.  See the following links regarding sessions...

Is it the PHP script or the flash script that will process this list of titles? I see several ways of doing this

1. Have the flash-player collect the list with a href like songinfo.php?id=4. The exact details I wouldn't know as I never learned to use flash.

2. Make a function (or class) in the songinfo.php script that will return the songlist. Then you do an include("songinfo.php") and call the function inside the jukebox.php script. (Example: getTitles(4);)

3. Use javascript to call additional files into the page (like the songinfo.php). This would be what is called AJAX.

If you need to collect the title-list repeatedly without reloading the page (jukebox.php) you would need to use method 1 or 3. On the other hand, if you need to collect this list only once, method 2 makes more sense. It would be faster as you have one less file to collect for the web browser.

There are probably other ways I have not thought about yet :P
Bruce GustPHP Developer


The thing is, the Flash file will always be looking for songInfo.php. I can't hope to embed anything within that URL because it won't be picked up within the Flash application. Right?

So, then I'm thinking I will script the songInfo.php file to pull from the database based on a session variable. So, from the catalog description, I'll have my user click on a link that will read something like jukebox.php?id=4. That page will be a resized window that takes the id and establishes it as a session id. That session id will be picked up by songInfo.php within the script and THAT's how I'll do it.

I haven't tried this, yet. Does that sound like a good approach?
It sounds like you are on the right track for using session variables however make sure that sessions are enabled in PHP and you use the session_start() command appropriately as the tutorial I pointed you to states. You don't really have to pass the variable in the URL either, I would have a link or button that when pressed sets the session variable and then loads the jukebox, also, since you are passing the variable to the jukebox already with ?id=4 then you could just use the $_GET['id'] variable in your jukebox script instead of the session variable.
Let me know if this makes sense or not, if you want to post some code showing how the jukebox script is working I could probably modify it so you can see an example.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.