Jump to content

[SOLVED] Echo all content in Database


AE117

Recommended Posts

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

Link to comment
Share on other sites

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
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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";
}

?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

[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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>.

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.