Hi all,
I'm facing a problem that I can't find a solution. I'm trying to creat a rss feed from a mysql table, the query I use in phpmyadmin is correct as I have the result I want but I can't call them, for some reason, in my php file. Here is the file
Code:
<?
header("Content-Type: text/xml; charset=utf-8");
// retrieve database records
include('conf/db.php');
if (!$db)
{
error_log("Error: Could not connect to database");
exit;
}
mysql_select_db("mydatabase");
$query1 = "select nomsite, url, description, date from annuaire_sites where valid='1' order by date limit 10";
$result1 = mysql_query($query1);
// display RSS 2.0 channel information
ECHO <<<END
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>My title</title>
<link>My link</link>
<description>My description</description>
<language>en-us</language>
<generator>My generator</generator>
END;
for ($i = 0; $i < mysql_num_rows($result1); $i++) {
@$row = mysql_fetch_array($result1);
$title = $row["nomsite"];
$link = $row["url"];
$description = $row["description"];
$date = $row["date"];
// display an item
ECHO <<<END
<item>
<title>$title</title>
<link>$link</link>
<description>$description</description>
<date>$date</date>
</item>
END;
}
ECHO <<<END
</channel>
</rss>
END;
?>
I'm fairly new into php/mysql/rss so I don't understand everything but with my limited knowledge it seems, for me, it's right and I only get as result <html><body/></html> which doesn't make sense.
Can anybody please help me out ?
Many thanks
|