Jump to content

[SOLVED] Help with code


steviez

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.