• Notice regarding image hosts and attachments. See here.

RSS to MySQL

Ok ive knocked up this little script to try and get something going but cant figure out why its not working, any idea's ?

PHP:
<?php
     include 'scripts/system/config.php';
    include 'scripts/system/opendb.php';

    $feedURL = 'cab-rss.xml';
    $doc = new DOMDocument();
    $doc->load($feedURL);
    $arrFeeds = array();
    foreach ($doc->getElementsByTagName('item') as $node) {
        $itemRSS = array ( 
        'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
        'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
        'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
        'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
        );
        array_push($arrFeeds, $itemRSS);

        foreach($arrFeeds as $arrItem) 
            {
               $query = "INSERT INTO newsfeed"
                . "(title, description, pubdate, url) "
                . "VALUES (".$arrItem['title'].", '".$arrItem['desc']."',".$arrItem['date'].",'".$arrItem['link']."')";
               $result = mysql_query($query) or die('Error, query failed');
            }
    }
    
    include 'scripts/system/closedb.php';
?>
 
Last edited:
Back
Top Bottom