Here's a rewritten version that might be a bit easier to read (and therefore debug):
<?php header('Content-Type: application/rdf+xml');?>
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:hr="http://www.w3.org/2000/08/w3c-synd/#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://www.example.com/news/news.php">
<title>Latest Info</title>
<description>Browse the latest.</description>
<link>http://www.example.com</link>
</channel>
<?php
include("../admin/config.php");
$sql = "SELECT category, adtext, id
FROM classifieds
WHERE postdate >= NOW() - INTERVAL 2 DAY
AND status = 'a'
ORDER BY RAND() DESC
LIMIT 3";
$result = mysql_query($sql, $conn) or die (mysql_error());
while ($row = mysql_fetch_array ($result)) {
?>
<item rdf:about="http://www.example.com">
<title><?php echo $row['category']?></title>
<description><?php echo $row['adtext']?></description>
<link>http://www.example.com/post/contact-seller.php?id=<?php echo $row['id']?></link>
</item>
<?
}
mysql_free_result ($result);
?>
</rdf:RDF>
That at least produces valid XML (assuming the contents of
$row['category'], $row['adtext'] etc., are themselves valid: they should
probably be run through [man]htmlspecialchars[/man] first just in case there's
an & or something in them somewhere).
But what is the content of this "extra
line"? Here's an awful rude hack that may give some results: Put a line at the end reading
<?php header('Content-Type: text/html');?>
The exact header is unimportant, what's important is the error message that results (assuming there is no output buffering specified). That error message will tell you which line of which script generated the very first bit of content in the XML page - in other words, the extra line that shouldn't be there.
And this really should have been started in a new thread.