Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts

    RSS feed date not right, it says its like 12900 days old when we add info today!

    <?php
    header('Content-type: text/xml');
    include("dbconfig.php");

    // the DATE_FORMAT is to make the date RFCwhatsit compliant
    $whatmonth = gmdate('m'); $whatyear = gmdate('Y'); $datetocheck = gmdate("Y-m-d H:i:s");
    $resultset = mysql_query("SELECT * FROM `sites` WHERE `confirmed` = '1' AND `linklocation` = 'main' AND `submitgmtdatetime` LIKE '&#37;$whatyear-$whatmonth%' AND `submitgmtdatetime` < '$datetocheck' ORDER BY `submitgmtdatetime` DESC") or die(mysql_error());

    echo("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n");
    ?>
    <rss version="2.0">
    <channel>
    <ttl>0</ttl>
    <title>RSS Feed</title>
    <link>http://site.com</link>
    <description>RSS Feed</description>
    <language>en-us</language>
    <pubDate><?=gmdate("D, d M Y H:i:s \G\M\T");?></pubDate>
    <lastBuildDate><?=gmdate("D, d M Y H:i:s \G\M\T");?></lastBuildDate>
    <generator>OnTheFly</generator>
    <image>
    <title><?=$sitename;?></title>
    <url>http://<?=$siteurl;?>/<? if ((gmdate("d") >= 1 && gmdate("m") == 12) || (gmdate("d") <= 4 && gmdate("m") == 1)) {?>images/xmas header.png<? } else { ?>images/header.png<? } ?></url>
    <link>http://<?=$siteurl;?>?s=rssimg</link>
    <width>88</width>
    <height>31</height>
    </image>
    <?php while ($result = @mysql_fetch_assoc($resultset)) {
    echo(" <item>\n");
    echo(" <title><![CDATA[$result[url]]]></title>\n");
    echo(" <link>http://$siteurl/?v=$result[id]&amp;h=r</link>\n");
    $py = substr($result[submitteddate], 0, 4);
    $pm = substr($result[submitteddate], 5, 2);
    $pd = substr($result[submitteddate], 8, 2);
    $ph = substr($result[submitteddate], 11, 2);
    $pm = substr($result[submitteddate], 14, 2);
    $ps = substr($result[submitteddate], 17, 2);
    $submitteddate = gmdate("D, d M Y H:i:s GMT", gmmktime($ph, $pm, $ps, $pm, $pd, $py));
    echo(" <pubDate>$submitteddate</pubDate>\n");
    echo(" <description>$result[desc]</description>\n");
    echo(" </item>\n\n");
    } ?>
    </channel>
    </rss>
    <?
    mysql_close();
    ?>

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Please put your code in [ p hp ] code blocks. Thanks

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bcarl314 View Post
    Please put your code in [ p hp ] code blocks. Thanks
    sorry to be an idiot but what is that?

    this is my php code

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    Why not store the submit-date as a timestamp in the database?
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by jasonc310771 View Post
    sorry to be an idiot but what is that?
    http://www.codingforums.com/showthread.php?t=68462

    [php]
    <?php
    echo 'example';
    ?>
    [/php]
    Becomes:
    PHP Code:
    <?php
    echo 'example';
    ?>
    It's easier to read, and syntax highlighted so errors will be easier to spot. You should also indent your code to make it that much more easier to read.

  • #6
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    PHP Code:
    <?php
    header
    ('Content-type: text/xml');
    include(
    "dbconfig.php");

    // the DATE_FORMAT is to make the date RFCwhatsit compliant
    $whatmonth gmdate('m'); $whatyear gmdate('Y'); $datetocheck gmdate("Y-m-d H:i:s");
    $resultset mysql_query("SELECT * FROM `sites` WHERE `confirmed` = '1' AND `linklocation` = 'main' AND `submitgmtdatetime` LIKE '%$whatyear-$whatmonth%' AND `submitgmtdatetime` < '$datetocheck' ORDER BY `submitgmtdatetime` DESC") or die(mysql_error());

    echo(
    "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n");
    ?>
    <rss version="2.0">
    <channel>
    <ttl>0</ttl>
    <title>RSS Feed</title>
    <link>http://site.com</link>
    <description>RSS Feed</description>
    <language>en-us</language>
    <pubDate><?=gmdate("D, d M Y H:i:s \G\M\T");?></pubDate>
    <lastBuildDate><?=gmdate("D, d M Y H:i:s \G\M\T");?></lastBuildDate>
    <generator>OnTheFly</generator>
    <image>
    <title><?=$sitename;?></title>
    <url>http://<?=$siteurl;?>/<? if ((gmdate("d") >= && gmdate("m") == 12) || (gmdate("d") <= && gmdate("m") == 1)) {?>images/xmas header.png<? } else { ?>images/header.png<? ?></url>
    <link>http://<?=$siteurl;?>?s=rssimg</link>
    <width>88</width>
    <height>31</height>
    </image>
    <?php while ($result = @mysql_fetch_assoc($resultset)) {
    echo(
    " <item>\n");
    echo(
    " <title><![CDATA[$result[url]]]></title>\n");
    echo(
    " <link>http://$siteurl/?v=$result[id]&amp;h=r</link>\n");
    $py substr($result[submitteddate], 04);
    $pm substr($result[submitteddate], 52);
    $pd substr($result[submitteddate], 82);
    $ph substr($result[submitteddate], 112);
    $pm substr($result[submitteddate], 142);
    $ps substr($result[submitteddate], 172);
    $submitteddate gmdate("D, d M Y H:i:s GMT"gmmktime($ph$pm$ps$pm$pd$py));
    echo(
    " <pubDate>$submitteddate</pubDate>\n");
    echo(
    " <description>$result[desc]</description>\n");
    echo(
    " </item>\n\n");
    ?>
    </channel>
    </rss>
    <?
    mysql_close
    ();
    ?>

    There you go I did it for you!

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    You're grabbing string positions from a string using "substr".

    Are you sure you're grabbing the correct locations for each variable?

    You should echo them all out and make sure.

    Other than that ... I agree with Gjay ... there must be a better
    way to do this. A timestamp would be so simple.
    http://us3.php.net/time


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •