1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php+rss

Discussion in 'PHP' started by gila, Nov 14, 2006.

  1. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    Got any person can help me?
    SEMrush
     
    gila, Nov 21, 2006 IP
    SEMrush
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #22
    Or try.

    
    $item->link = 'http://merd.com/news.php?n='. $data->newsid;
    
    PHP:
     
    nico_swd, Nov 22, 2006 IP
  3. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Thank You.
     
    gila, Nov 22, 2006 IP
  4. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #24
    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?
     
    gila, Nov 22, 2006 IP
  5. falcondriver

    falcondriver Well-Known Member

    Messages:
    963
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    145
    #25
    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.
     
    falcondriver, Nov 22, 2006 IP
  6. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #26

    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.
     
    gila, Nov 22, 2006 IP
  7. falcondriver

    falcondriver Well-Known Member

    Messages:
    963
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    145
    #27
    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.
     
    falcondriver, Nov 22, 2006 IP
  8. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #28

    sent via PM, Thank You.
     
    gila, Nov 22, 2006 IP
  9. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #29
    still got problem
     
    gila, Nov 23, 2006 IP
  10. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #30
    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?:confused: :confused: :confused:
     
    gila, Nov 28, 2006 IP
  11. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #31
    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?
     
    nico_swd, Nov 28, 2006 IP
  12. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #32
    
    $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
     
    gila, Nov 28, 2006 IP
  13. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #33
    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:
     
    nico_swd, Nov 28, 2006 IP
  14. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #34
    
    <? 
    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
     
    gila, Nov 28, 2006 IP
  15. PiecesMedia

    PiecesMedia Guest

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #35
    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. :)
     
    PiecesMedia, Nov 28, 2006 IP
  16. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #36
    i tried ....who can help me? pls
     
    gila, Nov 28, 2006 IP
  17. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #37
    who can help me? pls
     
    gila, Nov 29, 2006 IP
  18. gila

    gila Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #38
    Not any person can help me?
     
    gila, Nov 30, 2006 IP
  19. vishwaa

    vishwaa Well-Known Member

    Messages:
    271
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #39
    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.
     
    vishwaa, Dec 1, 2006 IP
  20. falcondriver

    falcondriver Well-Known Member

    Messages:
    963
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    145
    #40
    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.
     
    falcondriver, Dec 1, 2006 IP