Jump to content

Recommended Posts

Hi,

I run a music site and need to pull the file name of each song from the database when a user clicks on the track so the mp3 player can stream it.

I thought i had it working until i tryed it! it will pull the correct track from the database when the user has just come on to the site, but if they try to play another song it just streams the same one.

My code is as follows:

[code]<?php
$record_id = $_REQUEST['record_id'];
mysql_select_db($database_db, $db);
$query = "SELECT* FROM `audio`";
$RS_record = mysql_query($query, $db) or die(mysql_error());
$row_audio = mysql_fetch_assoc($RS_record);
$audio = $row_audio['audio'];
?>[/code]


Maybe someone can tell me if this is rite.
Where i want my track to be i place : [code]<?php echo $SITEURL ?><?php echo $AUDIO_URL ?><?php echo $audio; ?>[/code]

Any help would be great!

Thanks
Link to comment
https://forums.phpfreaks.com/topic/36112-solved-help-with-code/
Share on other sites

You obviously have a column in your database that's a unique field, probably auto-incrementing.  Is that $record_id?

If it is, then you will need to include that in the WHERE clause of your query.

[code=php:0]$query = "SELECT * FROM audio WHERE record_id = '$record_id'";[/code]

That should give you the correct track to stream.

This is obviously part of a much larger piece of code, so I can't comment on the bits you posted underneath the SQL code.

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/36112-solved-help-with-code/#findComment-171460
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.