I got timezone problem again. my rss show me <dc:date>2006-11-22T07:44:09+0800</dc:date> but my article date is 2006-11-22 03:44:09 why can be like that?
guess thats a feature of of this feed class. but leave it like it is, if you just have a "dd.mm.yyyy hh:mm:ss" in your feed you get an error with feed validators, you must include the timezone.
what your means? but i got saw other website that came from same country, they rss time is correct with they article, but mine one faster than my article four hours.
give me the 2 feed urls and i check it out. but as long as the feed validator dosnt complains its ok, dont change anything.
i try by this: $res = mysql_query("SELECT topic,newsid,desc,DATE_FORMAT(postdate, '%a, %e %b %Y %H:%i:%s GMT') AS postdate,author FROM news WHERE display = 1 ORDER BY postdate DESC LIMIT 0,10"); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); $item->title = $data->topic; $item->link = 'http://merd.com/news.php?n='. $data->newsid; $item->description = $data->desc; $item->date = $data->postdate; $item->source = "http://www.merd.com"; $item->author = $data->author; $rss->addItem($item) the rrs 'output like this only: <?xml version="1.0" encoding="gb2312" ?> - <!-- generator="FeedCreator 1.7.2" --> - <rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <channel rdf:about="http://www.merd.com/"> <title>xxxxx</title> <description>xxxxx</description> <link>http://merd.com/</link> <dc:date>2006-11-28T16:06:24+0800</dc:date> - <items> <rdf:Seq /> </items> </channel> </rdf:RDF> the date and time is wrong...why?
Hm, on another note, I think you should create the object before the loop. $item = new FeedItem(); while ($data = mysql_fetch_object($res)) { // ... PHP: And what exactly is wrong with the date?
$link = mysql_connect ($Host,$User,$Password); @mysql_select_db($DBName, $link); $res = mysql_query("SELECT topic,newsid,desc,DATE_FORMAT(postdate, '%a, %e %b %Y %H:%i:%s GMT') AS postdate,author FROM news WHERE display = 1 ORDER BY postdate DESC LIMIT 0,10"); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); $item->title = $data->topic; $item->link = 'http://merd.com/news.php?n='. $data->newsid; $item->description = $data->desc; $item->date = $data->postdate; $item->source = "http://www.merdw.com"; $item->author = $data->author; $rss->addItem($item); } Code (markup): output: <?xml version="1.0" encoding="gb2312" ?> - <!-- generator="FeedCreator 1.7.2" --> - <rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <channel rdf:about="http://www.merd.com/"> <title>XXX</title> <description>XXX</description> <link>http://merd.com/</link> <dc:date>2006-11-28T17:08:44+0800</dc:date> - <items> <rdf:Seq /> </items> </channel> </rdf:RDF> Error: Cannot display rss with fully and the date faster 4 hour. ---------------------------------------------------------------------- $link = mysql_connect ($Host,$User,$Password); @mysql_select_db($DBName, $link); $res = mysql_query("SELECT * FROM news WHERE display = 1 ORDER BY postdate DESC LIMIT 0,10"); while ($data = mysql_fetch_object($res)) { $item = new FeedItem(); $item->title = $data->topic; $item->link = 'http://merd.com/news.php?n='. $data->newsid; $item->description = $data->desc; $item->date = $data->postdate; $item->source = "http://www.merd.com"; $item->author = $data->author; $rss->addItem($item); } Code (markup): output: <?xml version="1.0" encoding="gb2312" ?> - <!-- generator="FeedCreator 1.7.2" --> - <rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <channel rdf:about="http://www.merd.com/"> <title>XXX</title> <description>XXX</description> <link>http://merd.com/</link> <dc:date>2006-11-28T17:11:17+0800</dc:date> - <items> - <rdf:Seq> <rdf:li rdf:resource="http://merd.com/news.php?n=3051" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3050" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3049" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3048" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3047" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3046" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3045" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3044" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3043" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3042" /> </rdf:Seq> </items> </channel> - <item rdf:about="http://merd.com/news.php?n=3051"> <dc:format>text/html</dc:format> <dc:date>2006-11-28T08:50:15+0800</dc:date> <dc:source>http://www.merd.com</dc:source> <dc:creator>Ioannis Gatsiounis</dc:creator> <title>XXXXXX</title> <link>http://merd.com/news.php?n=3051</link> <description>XXXXX</description> </item> ERROR: The article date is 2006-11-28 4:50 pm but the rss data display: 2006-11-28T08:50:15+0800
What do you mean with this? Does only one item show up? If so, try doing what I suggested earlier. Move this part before the loop. $item = new FeedItem(); PHP: Like this. $item = new FeedItem(); while ($data = mysql_fetch_object($res)) { $item->title = $data->topic; $item->link = 'http://merd.com/news.php?n='. $data->newsid; // .................. PHP:
<? include("feedcreator.class.php"); $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = "xxx"; $rss->description = "xxx"; $rss->link = "http://merd.com/"; $rss->syndicationURL = "http://www.merd.com/".$PHP_SELF; // get your news items from somewhere, e.g. your database: $User = ''; $Password= ''; $Host = 'localhost'; $DBName = ''; $link = mysql_connect ($Host,$User,$Password); @mysql_select_db($DBName, $link); $res = mysql_query("SELECT topic,newsid,desc,DATE_FORMAT(postdate, '%a, %e %b %Y %H:%i:%s GMT') AS postdate,author FROM news WHERE display = 1 ORDER BY postdate DESC LIMIT 0,10"); $item = new FeedItem(); while ($data = mysql_fetch_object($res)) { $item->title = $data->topic; $item->link = 'http://merd.com/news.php?n='. $data->newsid; $item->description = $data->desc; $item->date = $data->postdate; $item->source = "http://www.merd.com"; $item->author = $data->author; $rss->addItem($item); } $rss->saveFeed("RSS1.0", "news/feed.xml"); ?> Code (markup): output: <?xml version="1.0" encoding="gb2312" ?> - <!-- generator="FeedCreator 1.7.2" --> - <rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <channel rdf:about="http://www.merd.com/"> <title>XXX</title> <description>XXX</description> <link>http://merd.com/</link> <dc:date>2006-11-28T17:11:17+0800</dc:date> - <items> - <rdf:Seq> <rdf:li rdf:resource="http://merd.com/news.php?n=3051" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3050" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3049" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3048" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3047" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3046" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3045" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3044" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3043" /> <rdf:li rdf:resource="http://merd.com/news.php?n=3042" /> </rdf:Seq> </items> </channel> - <item rdf:about="http://merd.com/news.php?n=3051"> <dc:format>text/html</dc:format> <dc:date>2006-11-28T08:50:15+0800</dc:date> <dc:source>http://www.merd.com</dc:source> <dc:creator>Ioannis Gatsiounis</dc:creator> <title>XXXXXX</title> <link>http://merd.com/news.php?n=3051</link> <description>XXXXX</description> </item> ERROR: The article date is 2006-11-28 4:50 pm but the rss date display: 2006-11-28T08:50:15+0800
A great script i used for my PHP RSS feeds is CARP RSS. http://www.geckotribe.com/rss/carp/#getfree I'm not affilated with this site, i'm only speaking from experience. It's a great script if you want to add RSS feeds to the code of your pages, instead of just a link to the rss feed itself. Installation is easy and it's highly configurable.
1) Move $item = new FeedItem(); to its original location (inside the while loop) 2) Replace the following codes $res = mysql_query("SELECT topic,newsid,desc,DATE_FORMAT(postdate, '%a, %e %b %Y %H:%i:%s GMT') AS postdate,author FROM news WHERE display = 1 ORDER BY postdate DESC LIMIT 0,10"); PHP: to $res = mysql_query("SELECT topic,newsid,desc,UNIX_TIMESTAMP(postdate) AS postdate,author FROM news WHERE display = 1 ORDER BY postdate DESC LIMIT 0,10"); PHP: AND $item->date = $data->postdate; PHP: to $item->date = date('r',$data->postdate); PHP: It will convert the your post date to RFC 2822 format which is recommended for RSS. I hope this things will solve your problem.
no, tried this before and its not correct, validators will give you an error here. not sure where i have seen this, but there was some article about rss and you cant use a plain date("r", $timesamp) here.