This is EXACTLY what I have been looking for for days.. Can you tell me how that would go if I needed the xml file to read...
<songs>
<song title="songtitle" artist="bandname" path="mp3file"/>
<song title="songtitle" artist="bandname" path="mp3file"/>
<song title="songtitle" artist="bandname" path="mp3file"/>
<song title="songtitle" artist="bandname" path="mp3file"/>
<song title="songtitle" artist="bandname" path="mp3file"/>
</songs>
Here is the thing, I'm calling the info from my database called bschedule and the table is epk the fields within it are $name $songtitle $songlink
The info is already in the database.
I do want it to overwrite the xml file as the info in the database changes, as this works for a play list in a flash mp3 player.
Here is what I have tried from yours but am getting error each time...
<?php
include("epkheader.inc");
// read in the connection settings
require("bsadmin/dbconnection.txt");
// connect to the RDBMS
$db = mysql_connect("$site","$user","$pass")
or die_now("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");
// select the database
mysql_select_db("$database",$db)
or die_now("<h2>Could not select database $database</h2><p>Check database name</p>");
$link = "SELECT * FROM epk";
$result = mysql_query($link);
if (!$result) {
die('Could not query:' . mysql_error());
}
$row = mysql_fetch_assoc($result);
$name = strtoupper($name);
$songtitle = strtoupper($songtitle);
$songlink = strtoupper($songlink);
$thread .= '<songs ';
$thread .= 'song title="' . $songtitle . '";
$thread .= 'artist="' . $name . '";
$thread .= 'path="' . $songlink . '";
$thread .= '/>';
echo($thread);
$file = "songInfo.xml";
$contents = file($file);
$newcontents = "";
foreach($contents as $line) {
if(rtrim($line) != "<songs>") {
$newcontents .= $line;
}
else {
$newcontents .= $line;
$newcontents .= $thread . "\n";
}
}
$fp = fopen($file, "w");
fwrite($fp, $newcontents);
fclose($fp);
?>
<style type="text/css">
BODY {
margin-bottom:0;
margin-top:0;
margin-right:0;
margin-left:0;
background-color:none;
scrollbar-face-color:black;
scrollbar-highlight-color:black;
scrollbar-3dlight-color:gray;
scrollbar-darkshadow-color:black;
scrollbar-shadow-color: black;
scrollbar-arrow-color:gray;
scrollbar-track-color:black;
}
</style>
<title>MP3 player</title><body link="#CCCC00" vlink="#CCCC00" alink="#FFFFFF" text="#CCCCCC" >
<table width="36%" border="0" align="center">
<tr>
<td><b><font face="Arial, Helvetica, sans-serif" color="#FFFFFF">Sounds</font></b></td>
</tr>
<tr>
<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="340" height="171" align="absmiddle">
<param name=movie value="bsadmin/music/player.swf">
<param name=quality value=high><param name="SCALE" value="exactfit"><param name="BGCOLOR" value="#000000">
<embed src="bsadmin/music/player.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="340" height="171" align="absmiddle" scale="exactfit" bgcolor="#000000">
</embed>
</object></td>
</tr>
<tr>
<td><font color="#FFFFFF" face="Arial, Helvetica, sans-serif" size="2">Downloads:
</font></td>
</tr>
</table>
Any help would be greatly appreciated. XML confuses me greatly so I would love to be able to just do it this way. I am creating an edit form page to edit the contents in the playlist that will read back to the xml file from the php which will execute when the mp3 player is went to since it is in the php page.
Am I rambeling? haha. Sorry. I am excited to see if this thing can work.
Peredy