fanfavorite Posted November 6, 2008 Share Posted November 6, 2008 I have a flash player that reads in an XML file: http://www.myurl.ca/audioplayer/player?dataXml=http://www.myurl.ca/audioplayer1/audioxml.xml This works fine, but when I try to work use a php file http://www.myurl.ca/audioplayer/player?dataXml=http://www.myurl.ca/audioplayer1/audioxml.php the drop down menu of the flash does not display, even though if you go to audioxml.php it displays fine. In IE7, if I hit refresh, the menu displays fine (almost like it didn't finish loading the first time). In Firefox and other browsers, it just stays without the proper list in the drop down. The php file is like: header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="iso-8859-1"?>'; $url = "http://".getenv(HTTP_HOST)."/media/mp3/"; include('../includes/connection.php'); echo "\n<gallery>"; $CatArray[] = "0"; $count = 1; $q = mysql_query("SELECT * FROM MusicPlayer ORDER BY Category"); while($f = mysql_fetch_array($q)) { if (in_array($f[Category], $CatArray) == false) { if ($count != 1) { echo "\n\t</category>"; } echo "\n\t"; echo '<category name="'.$f[Category].'">'; $CatArray[] = $f[Category]; } $artist = strtoupper($f[Artist]); $song = strtoupper($f[songName]); echo "\n\t\t"; echo '<item mp3Path="'.$url.$f[Filename].'" played="0"><![CDATA[<font face="Font" color="#198a56">'.$artist.': </font><font face="Font" color="#FFFFFF">'.$song.'</font>]]></item>'; $count++; } echo "\n\t</category>"; echo "\n</gallery>"; Does anyone know why it would not be loading correctly? Is there a better way to create an XML file from dynamic MySQL data? Link to comment https://forums.phpfreaks.com/topic/131571-php-to-output-xml/ Share on other sites More sharing options...
fanfavorite Posted November 6, 2008 Author Share Posted November 6, 2008 I just changed it to see if using the XML DOM would work, but still the same result. <? $url = "../../media/mp3/"; include('../includes/connection.php'); $doc = new DOMDocument(); $doc->formatOutput = true; $r = $doc->createElement("gallery"); $doc->appendChild($r); $CatArray[] = "0"; $count = 1; $q = mysql_query("SELECT * FROM MusicPlayer ORDER BY Category"); while($f = mysql_fetch_array($q)) { if (in_array($f[Category], $CatArray) == false) { if ($count != 1) { $r->appendChild($b); } $b = $doc->createElement("category"); $b_attr1 = $doc->createAttribute('name'); $b->appendChild($b_attr1); $b_attr1->appendChild($doc->createTextNode($f[Category])); $CatArray[] = $f[Category]; } $artist = strtoupper($f[Artist]); $song = strtoupper($f[songName]); $item = $doc->createElement("item"); $item_attr1 = $doc->createAttribute('mp3Path'); $item->appendChild($item_attr1); $item_attr1->appendChild($doc->createTextNode($url.$f[Filename])); $item_attr2 = $doc->createAttribute('played'); $item->appendChild($item_attr2); $item_attr2->appendChild($doc->createTextNode('0')); $itemdata = '<font face="Font" color="#198a56">'.$artist.': </font><font face="Font" color="#FFFFFF">'.$song.'</font>'; $itemdata_cd = $doc->createCDATASection($itemdata); $item->appendChild($itemdata_cd); $b->appendChild($item); $count++; } $r->appendChild($b); echo $doc->saveXML(); ?> Link to comment https://forums.phpfreaks.com/topic/131571-php-to-output-xml/#findComment-683716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.