dropfaith Posted September 21, 2008 Share Posted September 21, 2008 So im working with rss and basicly im wondering what the best way to get and store the pubdate is.im assuming timestamp with a null of the current time is right but im just check also some pointers on getting the current time would be awesome for inserting into mysql. full code to display rss is below not sure why you would need it but meh <?php header('Content-type: text/xml'); ?> <rss version="2.0"> <channel> <title>Dropfaith Productions</title> <description>Rss Feed</description> <link>http://dropfaithproductions.com/layout/index.php</link> <copyright> http://dropfaithproductions.com/layout/index.php</copyright> <webmaster>dropfaith Productions</webmaster> <managingEditor>Matt Foley</managingEditor> <?php // includes include("template/conf.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $q="SELECT * FROM news ORDER BY Id DESC"; $doGet=mysql_query($q); while($result = mysql_fetch_array($doGet)){ ?> <item> <title><?=htmlentities(strip_tags($result['Title']));?></title> <description><?=htmlentities(strip_tags($result['News'],'ENT_QUOTES'));?></description> <link>http://dropfaithproductions.com/layout/permalink.php?Id=<?=$result['Id'];?></link> <pubDate><?=htmlentities(strip_tags($result['Date']));?></pubDate> </item> <?php } ?> </channel> </rss> Link to comment https://forums.phpfreaks.com/topic/125166-rss-feeds-and-pubdate/ Share on other sites More sharing options...
dropfaith Posted September 21, 2008 Author Share Posted September 21, 2008 bump? Link to comment https://forums.phpfreaks.com/topic/125166-rss-feeds-and-pubdate/#findComment-646995 Share on other sites More sharing options...
chronister Posted September 21, 2008 Share Posted September 21, 2008 The first thing I recommend is get rid of these <?= , if you port this code to a server that does not have short open tags set to on, then your code will fail. It is good coding practice to use <?php echo instead. As for the date, you can do a couple things. When you insert the row in the DB, you can use time() to get the current timestamp. Alternatively you can let mysql handle it. Set the data type for that row to timestamp and set the attributes to be on update current_timestamp. How are you setting the time field now? Nate Link to comment https://forums.phpfreaks.com/topic/125166-rss-feeds-and-pubdate/#findComment-647057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.