Jump to content

RSS Feed


Snatch

Recommended Posts

Hi, i'm trying to create a dynamic RSS feed for my site but i'm getting the following error:

 

Parse error: syntax error, unexpected T_DNUMBER in C:\xampp\htdocs\website\rss.php on line 11

 

The code i'm using is:

 

<?php

$connection = mysql_connect("localhost", "root", "");
mysql_select_db("shaw", $connection);

$select = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
$query = mysql_query($select) or die(mysql_error());

$file = fopen("rss.xml", "w");

fwrite($file, "<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>The Shadow Fox Feed</title>
<link>http://www.shadow-fox.net</link>
<description>Feed Description</description>
<language>en-us</language>");

while($array = mysql_fetch_array($query)){
extract($array);

$content = htmlentities($content);

fwrite($file, "<item>
<title>$title</title>
<link>http://www.shadow-fox.net/index.php?blog=post&id=$id</link>
<description>$content</description>
</item>");
}
//end of while loop

fwrite($file, "</channel></rss>");

fclose($file);

?>

 

Can anyone tell me whats going wrong please?

Link to comment
https://forums.phpfreaks.com/topic/84935-rss-feed/
Share on other sites

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.