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]?>" />
<?
}
?>

Link to comment
Share on other sites

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=""/>

Link to comment
Share on other sites

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=""/>

Link to comment
Share on other sites

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.

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.