Grow your CSS skills. Land your dream job.

Need help with PHP, mySQL and SimplePie

  • # August 8, 2012 at 1:03 pm

    I am building a website based on an RSS parser called SimplePie.

    I’ve been getting a headache trying to find a solution to what I thought was a simple problem.

    The code in question usually looks something like this:

     $feed->set_feed_url(array('http://www.tmz.com/rss.xml', 'http://rss.cbc.ca/lineup/topstories.xml')); 

    But I have a mySQL db that contains rows of URLs I am trying to insert dynamically.

    On StackOverflow, they suggested this:

     $rss_results = mysql_query("SELECT feed_id, feed_url, feed_title, feed_order, feed_page_id FROM user_feeds WHERE
    ((feed_owner = '" . $_SESSION . "'));");

    if ($rss_results) {

    $urls = array();
    while ($row = mysql_fetch_array($rss_results)) {

    $urls[] = $row;

    }
    $feed->set_feed_url($urls);
    }
    else {
    // something went wrong.
    echo mysql_error();
    }

    The code seemingly works. But the feeds are not in the right order. Feed items are supposed to be listed by date. Instead, feed items are grouped by feed and then ordered by date.

    The feed items are arranged correctly when I manually insert the values of the feeds. So if the code provided by StackOverflow worked as intended, it would be working. So I don’t think this is a problem with SimplePie.

    EDIT

    When I insert gibberish into the code…

        $urls[] = "dfsf" . $row . "fsdf";

    … the feed items are ordered correctly, but entire feeds are missing.

    I can’t make any sense of this. What could be the problem? Any suggestions?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".