xml - php - mysql
#1
Posted 04 May 2006 - 03:01 PM
1. Is it possible to have an mp3 uploaded to a database?
Then along with the mp3 I would enter the song name and band.
2. Is it possible to have the xml get the info from the database somehow?
I would like to make a very user friendly mp3 player.
This way the user could run the php script to enter the table. No mysql knowledge needed.
Then have a form where you upload the mp3 and also enter the song/band name.
Thanks..Hooch
#2
Posted 04 May 2006 - 03:09 PM
2. Yes
All the things you are asking can be done with PHP, MySQL, and XML
Edited by Chaos King, 04 May 2006 - 03:10 PM.
#3
Posted 04 May 2006 - 04:25 PM
I have been using FunkySoul's tut on mp3 players for awhile now.
So how would I impliment the xml/database connection from his script?
<?xml version='1.0' encoding='utf-8'?> <songs> <song name="Pixel2Life Soundtrack 01" file="music/p2l_01.mp3" /> <song name="Twodded Soundtrack 01" file="music/twod_01.mp3" /> </songs>Or is it more complicated, and I need to change the .swf and how it grabs
the info from the xml page?
tytytytyt very much
#4
Posted 05 May 2006 - 03:36 PM
#5
Posted 06 May 2006 - 10:52 PM
How would this code look to get an mp3 from a database?
<?xml version='1.0' encoding='utf-8'?> <songs> <song name="Pixel2Life Soundtrack 01" file="music/p2l_01.mp3" /> <song name="Twodded Soundtrack 01" file="music/twod_01.mp3" /> </songs>
If this was my database..
<?php include "includes/db.php"; $query = 'DROP TABLE `tunz`'; $result = mysql_query($query); $query = 'CREATE TABLE `tunz` ( id int(11) NOT NULL auto_increment, songname varchar(32) NOT NULL UNIQUE, band varchar(32) NOT NULL, mp3 varchar(32) NOT NULL, PRIMARY KEY (`id`)) ENGINE=INNODB;'; $result = mysql_query($query); echo "Table Created!"; ?>
Thank you..Hooch
#6
Posted 07 May 2006 - 07:38 AM
#7
Posted 15 May 2006 - 08:15 PM
I changed my actionscript in the .swf to link to my new playlist.php.
The old playlist.xml looked like this..
<?xml version='1.0' encoding='utf-8'?> <songs> <song name="Song" band="Band" File="music/Song.mp3" /> </songs>I had the new playlist.php actually working off the database. But it will not work with my old .swf file.
Here's the code for the new playlist.php
<?php header ("content-type: text/xml");
print "<?xml version=\"1.0\"?>\n";
mysql_connect("localhost", "*****", "****") or die ("<b>Unable to establish connection with MySQL.</b>\n");
mysql_select_db("****") or die ("<b>Unable to locate specified database.</b>");
$query = "SELECT * FROM music ORDER BY track_id ASC";
$result = mysql_query($query);
while($songs = mysql_fetch_object($result))
{
print "<songs>\n";
print "<name>".$songs->name."</name>\n";
print "<band>".$songs->band."</band>\n";
print "<File>".$songs->File."</File>";
print "</songs>\n";
}
?> Any ideas what I am doing wrong?
Thank you..
#8
Posted 15 May 2006 - 09:22 PM
http://darkpixels.ne...orial/php/id/6/
#9
Posted 16 May 2006 - 12:32 PM
The original actionscript (by funkysoul) for the childNodes are as follows...
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songFile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songFile[i] = playlist.firstChild.childNodes[i].attributes.File;
This is in conjunction with the following xml..
<?xml version='1.0' encoding='utf-8'?> <songs> <song name="Song" band="Band" File="music/Song.mp3" /> </songs>
Now would I need to change the above actionscipt for the following playlist.php?
<?php header ("content-type: text/xml");
print "<?xml version=\"1.0\"?>\n";
mysql_connect("localhost", "*****", "****") or die ("<b>Unable to establish connection with MySQL.</b>\n");
mysql_select_db("****") or die ("<b>Unable to locate specified database.</b>");
$query = "SELECT * FROM music ORDER BY track_id ASC";
$result = mysql_query($query);
while($songs = mysql_fetch_object($result))
{
print "<songs>\n";
print "<name>".$songs->name."</name>\n";
print "<band>".$songs->band."</band>\n";
print "<File>".$songs->File."</File>";
print "</songs>\n";
}
?>
Anyone see some correction needed??
#10
Posted 16 May 2006 - 02:00 PM
<?php header ("content-type: text/xml");
print "<?xml version=\"1.0\"?>\n";
mysql_connect("localhost", "*****", "****") or die ("<b>Unable to establish connection with MySQL.</b>\n");
mysql_select_db("****") or die ("<b>Unable to locate specified database.</b>");
$query = "SELECT * FROM music ORDER BY track_id ASC";
$result = mysql_query($query);
while($songs = mysql_fetch_object($result))
{
print "<songs>\n";
print "<song name=".$songs->name." band=".$songs->band." File=".$songs->File." />\n";
print "</songs>\n";
}
?>
That's using the xml format funkysoul used, give it a try
#11
Posted 16 May 2006 - 06:32 PM
but it was a no go.
Here's the error...
The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- A string literal was expected, but no opening quote character was found. Error processing resource 'http://www.@@@@.c/s... <song name=song01 band=band01 File=music/song01.mp3 /> -----------^
Hmmm...
**I was wondering if this needs to be changed in the action script since the playlist is in a php file instead of xml
playlist = new XML();
Edited by Hooch, 16 May 2006 - 07:33 PM.
#12
Posted 17 May 2006 - 06:49 PM
Here's my playlist.php
<?php
header ("content-type: text/xml");
print "<?xml version=\"1.0\"?>\n";
mysql_connect("localhost", "*****", "*****") or die ("<b>Unable to establish connection with MySQL.</b>\n");
mysql_select_db("*****") or die ("<b>Unable to locate specified database.</b>");
$query = "SELECT * FROM music ORDER BY track_id ASC";
$result = mysql_query($query);
print "<songs>\n";
while($songs = mysql_fetch_object($result))
{
print "<song name=\"".$songs->name."\" band=\"".$songs->band."\" File=\"".$songs->File."\" />\n";
}
print "</songs>";
?>
This will produce
<?xml version="1.0" ?> - <songs> <song name="song01" band="band01" File="music/song01.mp3" /> <song name="song02" band="band02" File="music/song02.mp3" /> </songs>But it still will not work with my mp3 player.
Once my playlist.php is equal to my playlist.xml do I need to change anything else?
I changed the link from my actionscript from playlist.xml to playlist.php
Thanks for any help
Hooch
#13
Posted 17 May 2006 - 08:13 PM
Once I tried from a new browser, it worked perfect!!
Thanks for all the help guys!!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
