Page 1 of 1

Problem formatting MySQL query results as XML.

Posted: Sun Nov 02, 2008 1:09 pm
by lgmcben
Hi, I'm trying to communicate with MySQL using PHP.

Actually I was following this:

http://livedocs.adobe.com/flex/3/html/d ... tml#193905



And here are the problem lines:
//////////////////////////////////////////////////////////////////////////
while ( $User = mysql_fetch_object( $Result ) )
{
$Return .= "<user><userid>".$User->userid."</userid><username>".$User->username."</username><emailaddress>".$User->emailaddress."</emailaddress></user>";
}
$Return .= "</users>";
mysql_free_result( $Result );
print ($Return)
//////////////////////////////////////////////////////////////////////////

I tried populating my table with some values before hand. (like samplename, sampleemail, ...)

After I run this php script(I didn't even involve with Flex yet, that's why I post here), the browser show something like this:

"1samplenamesamplemail2samplename2samplemail2" (of course, without the quotes)

instead of something like this:

<user>
<userid>1</userid>
<username>samplename</username>
<emailaddress>sampleemail</emailaddress>
</user>"
<user>
<userid>2</userid>
<username>samplename2</username>
<emailaddress>sampleemail2</emailaddress>
</user>"

What did I do wrong?

Thank you in advance. =)

Re: Problem formatting MySQL query results as XML.

Posted: Sun Nov 02, 2008 1:36 pm
by zephyr750
I have a feeling that you are doing nothing wrong. The browser is just processing the xml tags as HTML so the tags are not being displayed. Try viewing the source of you browser, you may find that the tags are there.

Re: Problem formatting MySQL query results as XML.

Posted: Sun Nov 02, 2008 2:27 pm
by cboileau
zephyr750 wrote:I have a feeling that you are doing nothing wrong. The browser is just processing the xml tags as HTML so the tags are not being displayed. Try viewing the source of you browser, you may find that the tags are there.
If you want the output to display as XML, simple add this to the top of your PHP script.

Code: Select all

header('Content-Type: text/xml');

Re: Problem formatting MySQL query results as XML.

Posted: Sun Nov 02, 2008 2:35 pm
by pavanpuligandla
hii..
i think u need to include php xml parser to read those values and displaying them in xml format.
c this,. http://in.php.net/manual/en/book.xmlwriter.php