AE117 Posted April 16, 2009 Share Posted April 16, 2009 Ok heres what I have <?php header("Content-type: text/xml"); $host = ""; $user = ""; $pass = ""; $database = ""; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT * FROM ost_media WHERE media_access='public'"; $resultID = mysql_query($query, $linkID) or die("Data not found."); while($r=mysql_fetch_array($resultID)) { $album=$r["media_id"]; $title=$r["media_title"]; } echo "<player showDisplay='yes' showPlaylist='yes' autoStart='yes'>\n"; {echo "<song path='$album' title='$title'/>";} echo "</player>\n"; ?> Which gives me this xml output <player showDisplay="yes" showPlaylist="yes" autoStart="yes"> <song path="106" title="Ronix Ibex Wakeboard 2009 Both Sides"/> </player> So what I need it to do is echo more than that one song, the fetch command is saying get all those files that have public access but im only echoing one and i dont know how to echo all the results. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/ Share on other sites More sharing options...
MasterACE14 Posted April 16, 2009 Share Posted April 16, 2009 change this... <?php $query = "SELECT * FROM ost_media WHERE media_access='public'"; to this... <?php $query = "SELECT * FROM ost_media"; Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811297 Share on other sites More sharing options...
trq Posted April 16, 2009 Share Posted April 16, 2009 Move your echo statements into the while loop. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811298 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Share Posted April 16, 2009 as pointed out by thorpe <?php while($r=mysql_fetch_array($resultID)) { $album=$r["media_id"]; $title=$r["media_title"]; }// move this fella echo "<player showDisplay='yes' showPlaylist='yes' autoStart='yes'>\n"; {echo "<song path='$album' title='$title'/>";} echo "</player>\n"; }//down here ?> Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811300 Share on other sites More sharing options...
AE117 Posted April 16, 2009 Author Share Posted April 16, 2009 as pointed out by thorpe <?php while($r=mysql_fetch_array($resultID)) { $album=$r["media_id"]; $title=$r["media_title"]; }// move this fella echo "<player showDisplay='yes' showPlaylist='yes' autoStart='yes'>\n"; {echo "<song path='$album' title='$title'/>";} echo "</player>\n"; }//down here ?> Ok I did that and now i get XML Parsing Error: junk after document element Location: http://music.eevoke.com/flash%20mp3/testxmlphp.php Line Number 3, Column 1:<player showDisplay='yes' showPlaylist='yes' autoStart='yes'> ^ not sure what that means but thats what it says. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811305 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 You can't just blindly copy what jesushax wrote, read the comments next to the closing brackets. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811308 Share on other sites More sharing options...
AE117 Posted April 16, 2009 Author Share Posted April 16, 2009 You can't just blindly copy what jesushax wrote, read the comments next to the closing brackets. I did read it and that is the error I got. I moved the bracket down to enclose the echo statements and still got the error <?php header("Content-type: text/xml"); $id = "public"; $host = "localhost"; $user = "eevoke_admin2"; $pass = "3T4JI2ny2QFp"; $database = "eevoke_ostube"; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT * FROM ost_media WHERE media_access='public'"; $resultID = mysql_query($query, $linkID) or die("Data not found."); while($r=mysql_fetch_array($resultID)) { $album=$r["media_id"]; $title=$r["media_title"]; echo "<player showDisplay='yes' showPlaylist='yes' autoStart='yes'>\n"; echo "<song path='$album' title='$title'/>"; echo "</player>\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811309 Share on other sites More sharing options...
jesushax Posted April 16, 2009 Share Posted April 16, 2009 firstly id craete a include file and keep my db connection info in there connection.php <?php $uname = 'eevoke_admin2'; $pass = '3T4JI2ny2QFp'; $db_name = 'eevoke_ostube'; $host = 'localhost'; $con = mysql_connect($host, $uname, $pass); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($db_name, $con); if (!$db_selected) { die ('Can\'t use database : ' . mysql_error()); } ?> then at the top of all the pages you use a database on include($_SERVER['DOCUMENT_ROOT'] . '/connection.php'); that will save you copy and pasting your db connection all the time, and stop you accidently posting yoru login details on a public forum, lucky your db is stored locally your problem lies with some xml your using or including elsewhere do you want to just write the information to a page or do you have formatting to it grabbed elsewhere? Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811314 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 Can you post the first 4 lines of the resulting XML file please? View source in your browser should let you see it. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811315 Share on other sites More sharing options...
AE117 Posted April 16, 2009 Author Share Posted April 16, 2009 [quote] include($_SERVER['DOCUMENT_ROOT'] . '/connection.php'); that will save you copy and pasting your db connection all the time, and stop you accidently posting yoru login details on a public forum, lucky your db is stored locally your problem lies with some xml your using or including elsewhere do you want to just write the information to a page or do you have formatting to it grabbed elsewhere? yea that is a good point I wasnt even thinking about it because its just testing but I see your point. I want it to be in a xml format so a flash file can use that information to populate. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811321 Share on other sites More sharing options...
AE117 Posted April 16, 2009 Author Share Posted April 16, 2009 Can you post the first 4 lines of the resulting XML file please? View source in your browser should let you see it. at the moment it just goves this XML Parsing Error: junk after document element Location: http://music.eevoke.com/flash%20mp3/testxmlphp.php Line Number 3, Column 1:<player showDisplay='yes' showPlaylist='yes' autoStart='yes'> ^ but before moving the echo inside the while statement it looked like <player showDisplay="yes" showPlaylist="yes" autoStart="yes"> <song path="106" title="Ronix Ibex Wakeboard 2009 Both Sides"/> </player> Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811323 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 And a view source shows: <song path='16' title='95 Ford Prode GT'/> <song path='17' title='1997 Eagle Talon'/> <song path='18' title='1997 Eagle Talon'/> <song path='19' title='300zx Twin Turbo vs ZX10R'/> Which implies that you've somehow lost the lines that echo the <player ...> and </player>. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811327 Share on other sites More sharing options...
AE117 Posted April 16, 2009 Author Share Posted April 16, 2009 And a view source shows: <song path='16' title='95 Ford Prode GT'/> <song path='17' title='1997 Eagle Talon'/> <song path='18' title='1997 Eagle Talon'/> <song path='19' title='300zx Twin Turbo vs ZX10R'/> Which implies that you've somehow lost the lines that echo the <player ...> and </player>. Well that is because i removed it but now its back but let me get this straight even though the page has and error but the view source shows the information the flash file will be able to read the content? Or is it going to stop my flash app from getting the data? Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811331 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 The flash file will be able to read the content but I would expect it will require valid xml. Your browser is displaying the error message. Whether it can parse that content is a question that probably only you can answer. Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811339 Share on other sites More sharing options...
AE117 Posted April 16, 2009 Author Share Posted April 16, 2009 The flash file will be able to read the content but I would expect it will require valid xml. Your browser is displaying the error message. Whether it can parse that content is a question that probably only you can answer. Just need to add a couple more lines so flash knows its encoding but I greatly appreciate the help. Thank You Quote Link to comment https://forums.phpfreaks.com/topic/154319-solved-echo-all-content-in-database/#findComment-811346 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.