Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP code help

Options
  • 18-01-2005 7:13pm
    #1
    Registered Users 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 Posts: 3,330 ✭✭✭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 Posts: 6,511 ✭✭✭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 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 Posts: 68,317 ✭✭✭✭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 Posts: 1,747 ✭✭✭Figment


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


Advertisement