Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP code help

  • 18-01-2005 06:13PM
    #1
    Registered Users, Registered Users 2 Posts: 1,747 ✭✭✭


    I am not a PHP coder so sorry if this is something very stupid.

    I have this bit of code to parse an rss feed on a site. I cant get it to work.
    Its an RSS 1.0 feed.
    Its giving me this error:
    atal error: Call to undefined function: simplexml_load_file() in /xxxxxxxxxxxxxx/temp/news_test.php on line 93

    Any suggestions/help welcome.

    Thanks,
    Alan

    <?php
    /**********************************
    * phpRSS - Simple PHP5 RSS parser *
    * ------------------------------- *
    * by:    Kelli Shaver             *
    *        kelli@kellishaver.com    *
    *        www.kellishaver.com      *
    * ------------------------------- *
    * This is a simple function to    *
    * parse an RSS formated XML file. *
    * As you can see, it only handles *
    * the required elements, title,   *
    * description and link, but it is *
    * very straightforward and easy   *
    * to use and expand upon.         *
    * ------------------------------- *
    * Distributed under the terms and *
    * conditions of the GNU general   *
    * public license. - www.gnu.org   *
    * ------------------------------- *
    * Usage: include "phprss.php";    *
    *        parseRSS("http://xxxxxxxxxx/e_rss.aspx");  *
    * ------------------------------- *
    * Last modified: 10/29/2004       *
    **********************************/
    
    parseRSS("http://xxxxxxxxxx/e_rss.aspx");
    function parseRSS($src) {
    
        $feed = simplexml_load_file($src);
    
        printf ('<h1>
                <a href="%s" title="%s">%s</a>
            </h1>
            <p>%s</p>',
    
            $feed->channel->link,
            $feed->channel->title,
            $feed->channel->title,
            nl2br($feed->channel->description)
        );
    
        foreach($feed->channel->item as $res) {
            printf('<h2>
                    <a href="%s" title="%s">%s</a>
                </h2>
                <p>%s</p>',
        
                $res->link,
                $res->title,
                $res->title,
                nl2br($res->description)
            );
        }
    }
    ?>
    


Comments

  • Registered Users, Registered Users 2 Posts: 3,363 ✭✭✭radiospan


    I'm no expert, but I believe the simplexml_load_file() function that script is calling requires PHP5.

    Most webservers are probably still running PHP 4.x


  • Registered Users, Registered Users 2 Posts: 6,680 ✭✭✭daymobrew


    http://us2.php.net/manual/en/function.simplexml-load-file.php
    confirms what plazzTT says - this is a PHP 5 function.


  • Closed Accounts Posts: 2,525 ✭✭✭JustHalf


    As PHP5 breaks a lot of PHP4 apps (like PHPBB2 !!!) I think it will be difficult to find a host who offers that on their standard package.

    That's a fairly simple script though, I'm sure someone could write on for you in PHP4 or Perl pretty quickly, if you can't find a similar one elsewhere.


  • Registered Users, Registered Users 2 Posts: 1,747 ✭✭✭Figment


    Thats the problem, thanks guys.

    There must be a script already floating around Justhalf, i will take a look.

    Chears.


  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    JustHalf wrote:
    As PHP5 breaks a lot of PHP4 apps (like PHPBB2 !!!) I think it will be difficult to find a host who offers that on their standard package.
    There's a hack on sourceforge to allow you to run phpbb 2.0.11 on PHP5. Had to install it the other day after a client's host brilliantly decided to upgrade without telling anyone.


  • Advertisement
  • Closed Accounts Posts: 2,525 ✭✭✭JustHalf


    We had so many compatability problems on Minds, that in the end we just went back to using PHP4. Far easier than trying to plug every single hole.


  • Registered Users, Registered Users 2 Posts: 1,747 ✭✭✭Figment


    Thanks all. Ended up using this script.
    http://geek.scorpiorising.ca/rss.html


Advertisement