 |
|
|
01-02-2011, 09:38 AM
|
RSS pubDate issue?
|
Posts: 8
|
Hi,
I'm desperately hoping someone can assist with this issue, it's driving me insane.
An RSS feed I'm looking to implement is throwing up every news update time as Thu, 01 Jan 1970 1:00 - seen here
Quote:
|
<pubDate><?=date("D, d M Y G:i", $row['date']); ?></pubDate>
|
I'm at loss how to resolve the issue.
Any help would be greatly appreciated!
|
|
|
|
01-02-2011, 09:51 AM
|
Re: RSS pubDate issue?
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
$row['date'] is either not set or is set to 0.
Also, don't use short codes (<?= and <?). Using them ensures that your code won't be portable and isn't future proof.
|
|
|
|
01-02-2011, 09:59 AM
|
Re: RSS pubDate issue?
|
Posts: 8
|
Quote:
Originally Posted by NullPointer
$row['date'] is either not set or is set to 0.
Also, don't use short codes (<?= and <?). Using them ensures that your code won't be portable and isn't future proof.
|
Many thanks for your help.
Could you please explain how do I set $row['date'] ?
|
|
|
|
01-02-2011, 11:16 AM
|
Re: RSS pubDate issue?
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
Short answer:
PHP Code:
$row['date'] = 'some value';
Long answer:
I'm guessing this that $row is a row from a sql database maybe? You might want to look into why 'date' is not being set. Make sure there is a date column in your table and look through the data to make sure the values aren't null.
Posting your code might help.
|
|
|
|
01-02-2011, 11:49 AM
|
Re: RSS pubDate issue?
|
Posts: 8
|
Quote:
Originally Posted by NullPointer
Short answer:
PHP Code:
$row['date'] = 'some value';
Long answer:
I'm guessing this that $row is a row from a sql database maybe? You might want to look into why 'date' is not being set. Make sure there is a date column in your table and look through the data to make sure the values aren't null.
Posting your code might help.
|
Many thanks for your continued help.
I've inherited the code so struggling a little bit.
rss/index.php code;
Code:
<?php
header( 'Content-type: text/xml' );
define('IN_MCMS', 'public');
require_once('../conf/conf.php');
require_once('../classes_functions/sql.php');
$SITE = new MySQL ( $CONF['host'] , $CONF['username'] , $CONF['password'] , $CONF['database'] );
echo ( '<?xml version="1.0" encoding="iso-8859-1" ?>' )
?>
<rss version="2.0">
<channel>
<title>GrandOldTeam News RSS</title>
<link>http://www.grandoldteam.com</link>
<description>Latest news from GrandOldTeam</description>
<language>en-uk</language>
<generator>GrandOldTeam.com</generator>
<?php
$query = $SITE -> Query ( 'SELECT title, article, url, category FROM got_news ORDER BY pub_date DESC LIMIT 0,15' );
while($row = $SITE -> FetchArray($query)) {
if ($row['category'] == 'Match Report') {
$PAGE['url'] = 'match-reports';
} else if ($row['category'] == 'Match Preview') {
$PAGE['url'] = 'match-previews';
} else if ($row['category'] == 'Reserves, Youth & Ladies') {
$PAGE['url'] = 'reserves-youth-ladies';
} else {
$PAGE['url'] = str_replace(' ', '-', strtolower($row['category']));
}
?>
<item>
<title><![CDATA[<?=html_entity_decode($row['title']); ?>]]></title>
<link><?=$CONF['site']; ?>news/<?=$PAGE['url']; ?>/<?=$row['url']; ?></link>
<description><![CDATA[<?=strip_tags(html_entity_decode(substr($row['article'], 0, strpos($row['article'], "\n")))); ?>]]></description>
<category><![CDATA[<?=$row['category']; ?>]]></category>
<pubDate><?=date("D, d M Y G:i", $row['date']); ?></pubDate>
</item>
<?php
}
?>
</channel>
</rss>
sql;

|
|
|
|
01-02-2011, 12:01 PM
|
Re: RSS pubDate issue?
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
It looks like $row['date'] should be $row['pub_date']. Right now it doesn't look like pub_date is included in the query so you'll have to change:
Code:
SELECT title, article, url, category FROM got_news ORDER BY pub_date DESC LIMIT 0,15
to
Code:
SELECT title, article, url, category, pub_date FROM got_news ORDER BY pub_date DESC LIMIT 0,15
|
|
|
|
01-02-2011, 12:07 PM
|
Re: RSS pubDate issue?
|
Posts: 8
|
Didn't seem to do the trick I'm afraid.
Do you have any other suggestions?
Quote:
SELECT title, article, url, category FROM got_news ORDER BY pub_date DESC LIMIT 0,15
Warning: Cannot modify header information - headers already sent by (output started at /home/grandold/public_html/rss/index.php:2) in /home/grandold/public_html/rss/index.php on line 3
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/grandold/public_html/rss/index.php:2) in /home/grandold/public_html/conf/conf.php on line 8
http://www.grandoldteam.com Latest news from GrandOldTeam en-uk GrandOldTeam.com http://www.grandoldteam.com/news/gen...1/jan/02/xxxxx Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/gen...11/jan/02/aaa2 Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/gen...randoldteamcom Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/gen...rimed-for-duty Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/gen...-bemoans-break Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/tra...aughan-reports Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/tra...0/yak-to-leave Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/tra...on-chase-kucka Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/mat...ity-vs-everton Thu, 01 Jan 1970 1:00 http://www.grandoldteam.com/news/gen...011/jan/02/aaa Thu, 01 Jan 1970 1:00
|
|
|
|
|
01-02-2011, 12:41 PM
|
Re: RSS pubDate issue?
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
What exactly did you do? I meant for you to change this line:
PHP Code:
$query = $SITE -> Query ( 'SELECT title, article, url, category FROM got_news ORDER BY pub_date DESC LIMIT 0,15' );
to
PHP Code:
$query = $SITE -> Query ( 'SELECT title, article, url, category, pub_date FROM got_news ORDER BY pub_date DESC LIMIT 0,15' );
and this line:
PHP Code:
<pubDate><?= date("D, d M Y G:i", $row['date']); ?></pubDate>
to
PHP Code:
<pubDate><?php echo date("D, d M Y G:i", $row['pub_date']); ?></pubDate>
The query should not be in the output.
Last edited by NullPointer; 01-02-2011 at 12:42 PM..
|
|
|
|
01-02-2011, 12:46 PM
|
Re: RSS pubDate issue?
|
Posts: 8
|
Your a star. Fixed.
Many, many thanks.
|
|
|
|
|
« Reply to RSS pubDate issue?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|