Jump to content

Recommended Posts

Hello,

 

I have the following php code that should return a rss page, but the problem is that nothing from my sql data base appears on the rss page. All the connection info are correct. Can you tell me why doesn't return any article??

Thanks

 

<?php $db = new mysqli("localhost", "user", "pass", "site_db"); ?>
<?php header('Content-type: text/xml'); ?>
<?php echo "<?";?>xml version="1.0" encoding="iso-8859-1"<?php echo "?>";?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Quantic Lab</title>
		<link>http://www.quanticlab.com</link>
		<description>Press Releases</description>
		<language>en-us</language>
		<copyright>2009 Quantic Lab</copyright>
		<pubDate>Tue, 10 Apr 2009 22:31:45 EDT</pubDate>
		<lastBuildDate>Tue, 10 Apr 2009 22:31:45 EDT</lastBuildDate>
		<category>Quality Assurance</category>
		<generator>QL RSS Generator</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.quanticlab.com/feed/Sigla_alb.jpg</url>
			<title>Quantic Lab</title>
			<link>http://www.quanticlab.com</link>
			<height>95</height>
			<width>133</width>
			<description>Quality Assurence</description>
		</image>
<?php

$query = "SELECT * FROM news";
$results = $db->query($query);
$number = $results->num_rows;

for ($i = 1; $i <= $number; $i++) {

$row = $results->fetch_assoc();

$title = $row['news_titlu'];
$description = $row['news_short'];
$link = "http://www.quanticlab.com/press.php?id_news=".$row['id_news'];
$date = date("r", $row['timestamp']);

?>
<item>
<title><?php echo $title; ?></title>
<description><?php echo $description; ?></description>
<link><?php echo $link; ?></link>
<pubDate><?php echo $date; ?></pubDate>
<guid><?php echo $link; ?></guid>
</item>
<?php

}

?>
</channel>
</rss>
<?php

$db->close();

?>

Link to comment
https://forums.phpfreaks.com/topic/153453-rss-for-web-site/
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.