Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-02-2011, 09:38 AM RSS pubDate issue?
Novice Talker

Posts: 8
Trades: 0
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!
Evertonian is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-02-2011, 09:51 AM Re: RSS pubDate issue?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
$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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-02-2011, 09:59 AM Re: RSS pubDate issue?
Novice Talker

Posts: 8
Trades: 0
Quote:
Originally Posted by NullPointer View Post
$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'] ?
Evertonian is offline
Reply With Quote
View Public Profile
 
Old 01-02-2011, 11:16 AM Re: RSS pubDate issue?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-02-2011, 11:49 AM Re: RSS pubDate issue?
Novice Talker

Posts: 8
Trades: 0
Quote:
Originally Posted by NullPointer View Post
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 &amp; 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;



Evertonian is offline
Reply With Quote
View Public Profile
 
Old 01-02-2011, 12:01 PM Re: RSS pubDate issue?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-02-2011, 12:07 PM Re: RSS pubDate issue?
Novice Talker

Posts: 8
Trades: 0
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
Evertonian is offline
Reply With Quote
View Public Profile
 
Old 01-02-2011, 12:41 PM Re: RSS pubDate issue?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 01-02-2011 at 12:42 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-02-2011, 12:46 PM Re: RSS pubDate issue?
Novice Talker

Posts: 8
Trades: 0
Your a star. Fixed.

Many, many thanks.
Evertonian is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to RSS pubDate issue?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47507 seconds with 12 queries