Jump to content

[SOLVED] XML file works if I don't use a query


brooksh

Recommended Posts

I can't seem to figure this out. If I manually input the image source it works, but if I use a query it errors out. In the header I am using:

header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';

 

In the content I have

<image source="house.jpg" title="Front view" description=""/>

But if I use this query instead it doesn't work. I have verified that the query is good.

 

<?
$result = mysql_query("SELECT DISTINCT name,caption,description,rank FROM images WHERE id = '$id' ORDER BY rank");
while($row = mysql_fetch_array($result)){
?>
<image source="<?=$row[file_name]?>" title="<?=$row[caption]?>" description="<?=$row[description]?>" />
<?
}
?>

The query works. When I call the xml file and manually input the info, the pictures show up, but if I use a query it doesn't work. When looking at the xml file, they look identical.

 

Manual:

<image source="image18.jpg" title="test" description=""/>

sql query:

<image source="image14.jpg" title="Front view" description=""/>

I'm going to have to disagree with you haku.

 
<?php
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

This works just fine as a php file. The way this script is used, it is actually called as source, not src. Like I mentioned before, it works fine if I manually input

<image source="image18.jpg" title="test" description=""/>

It was worth a shot but <![CDATA]]> didn't work.

 

Haku. How is this closing my xml tag? I did try what you said, but it just gave me errors because I want it to echo

<?xml version="1.0" encoding="UTF-8"?> and if I close it off with a single quote I can echo it. I reads just fine if I view source.

echo '<?xml version="1.0" encoding="UTF-8"?>';

I have used this exact header in different php xml files.

Archived

This topic is now archived and is closed to further replies.

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