By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

XML file in PHP

P: 78
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <config>
  3.  
  4.     <param name="mp3" value="Aise Na Mujhe.mp3|musicfiles/49_All_Praise_to_You__Eternal_Lord.mp3|musicfiles/49_Christians_Awake.mp3|musicfiles/49_Comfort_and_Joy.mp3|musicfiles/49_Down_from_His_Glory.mp3|musicfiles/49_Jesus__You_re_Worth_Everything.mp3|musicfiles/49_Jesus_Christ_is_Risen_Today.mp3|musicfiles/49_Mother_s_Christmas_Night.mp3|musicfiles/49_Rebuilding.mp3|musicfiles/49_Saw_You_Never.mp3|musicfiles/49_The_Love_of_God_is_Greater_Far.mp3" />
  5.  
  6.  
  7.  
  8.  
  9.     <param name="title" value="Aise Na Mujhe.mp3" />
  10.     <param name="height" value="150" />
  11.     <param name="width" value="225" />    
  12.     <param name="bgcolor1" value="fbdb03" />
  13.     <param name="bgcolor2" value="fbdb03" />
  14.     <param name="buttoncolor" value="090909" />
  15.     <param name="buttonovercolor" value="0aaf01" />
  16.     <param name="slidercolor1" value="babababa" />
  17.     <param name="slidercolor2" value="cccccc" />
  18.     <param name="sliderovercolor" value="10a905" />
  19.     <param name="textcolor" value="000000" />
  20.     <param name="playlistcolor" value="813d07" />
  21.     <param name="currentmp3color" value="ffffff" />
  22.     <param name="scrollbarcolor" value="000000" />
  23.     <param name="scrollbarovercolor" value="288404" />
  24.     <param name="showvolume" value="1" />
  25.     <param name="showinfo" value="1" />
  26.  
  27.  
  28. </config>
  29.  
This is my XML file. and I am using swf player to play the songs.
My problem is I want to fetch the data(mp3 file in my musicfile folder and path in my database) from phpmyadmin database to this xml file. Is it possible?

please help me friends..........

--Ammu
Mar 16 '12 #1
Share this Question
Share on Google+
3 Replies


dlite922
Expert 100+
P: 1,584
Yes it's possible. You need to connect to your database using combination of the following functions: mysql_connect() mysql_select_db(), mysql_query() and mysql_fetch_<type>();

Checkout the PHP manual at php.net if you don't know how to use any of these functions.

Good luck,


Dan
Mar 16 '12 #2

P: 78
Thank you for your response......

yes i know these functions to fetch the data from database. But my probelm is i want to write these codes in xml file. my file is songs.xml
Expand|Select|Wrap|Line Numbers
  1. $conn=mysql_connect("localhost","root","")or die("Unable to connect");
  2. $select=mysql_select_db("sample",$conn) or die("Unable to connect");
  3.  
i tried to write this php connection code in xml file but not working shows error

--Ammu
Mar 17 '12 #3

Expert 100+
P: 1,032
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $string = <<<XML
  4. <?xml version="1.0" encoding="UTF-8"?>
  5.   <config>
  6.   </config>
  7. </xml>
  8. XML;
  9.  
  10. $xml = new SimpleXMLElement(<<<EOXML
  11. <?xml version="1.0" encoding="UTF-8"?>
  12. <config>
  13. </config>
  14. EOXML
  15. );
  16.  
  17. $item = $xml->addChild('param', '');
  18. $item->addAttribute('name', 'mp3');
  19. $item->addAttribute('value', 'something');
  20.  
  21. $item = $xml->addChild('param', '');
  22. $item->addAttribute('name', 'height');
  23. $item->addAttribute('value', '150');
  24.  
  25. echo $xml->asXML();
  26.  
  27. ?>
  28.  
Mar 29 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.