Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Variables from Database, MySQL/PHP

Status
Not open for further replies.

adpat79

Technical User
May 9, 2007
2
GB
Hi,

I am currently trying to add a music player to my social network website that allows users to upload their own tracks and play them through an mp3 player embedded in their profile page.

The problem i am having is that i want the mp3 player to read the track name, artist name, and the file location from the database.

I have written my PHP file to query the database but cant get the flash file to read the variables out.

I am foremost a designer and not the best programmer, so i was hoping someone could help as i have tried numerous tutorials and still cant quite get it.

The mp3 player works when loading the mp3 files from a URL, and the PHP file is pulling out the varaibles form the database succesfully, it has just hit problems when loading the variables from the database into the flash, i know it is the Actionscript but i cant work it out as yet....

My PHP code is:

<?php

require('../includes/adodb_setup.inc');

$id = $_GET['id'];

$sql = "SELECT * FROM person LEFT JOIN tracks ON person.person_musictrack = tracks.track_ID WHERE person.person_ID = '$id'";
$result = mysql_query($sql) or die("<b>error</b>: failed to execute query <i>$query</i>");



$desiredContent = mysql_fetch_array($result, MYSQL_ASSOC);
mysql_free_result($result);

//echo "$desiredContent[track_artist]";

print "filename=$desiredContent[track_filename]&artist=$desiredContent[track_artist]&track=$desiredContent[track_title]";

?>

And my Action Script is:

myVars = new LoadVars();
// call the load method to load my php page
myVars.load("// once vars have been loaded, we will have these variables:



//----------------<sound initialization>----------------\\
var bgMusak:Sound;
bgMusak.setVolume(100);
this.trackInfo.autoSize = "left";

playMusak();
//----------------<sound setup>----------------\\
function pauseMusak(){
delete bgMusak;
};

function playMusak() {

bgMusak = new Sound();
bgMusak.loadSound(myVars.filename, true);
artistInfo.text = (myVars.artist);
trackInfo.text = (myVars.track);



bgMusak.onLoad = function(success) {
if (!success) {
trackInfo.text = "Failed to load track.";
}
};

};


Can anyone help me?

Thanks....
 
Hi Bill....

What an absolute legend you are!!

Ha... With a few more tweaks this morning i have a fully functional mp3 player which allows people to add their own tracks to their profile pages and enables them to add tracks from other members pages...

Headache over... :)

Many Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top