My first xml try

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I must use php 4 and mysql 4.x !

I tried an example I found on the net and modified it so that it should
work with php4 and mysql 4. The code is below.
I need to access a database and get an xml feed output.
I tried to use echo statements for debugging and found that it seems I
do not get the information of require().

What do I need to change?

bye

Ronald

|<?
    header("Content-Type: application/xml; charset=ISO-8859-1");

class RSS
{
    function RSS()
    {
        require("../mysyql-config");
    }
    
    function GetFeed()
    {
        return $this->getDetails() . $this->getItems();
    }
    
    
    function getDetails()
    {
        $detailsTable = "webref_rss_details";
        $query = "SELECT * FROM ". $detailsTable;
        $db = mysql_connect($dbhost, $dbuname, $dbpass);
        mysql_select_db($dbname,$db);
        $result = mysql_query($query, $db);
//    echo "dbhost=$dbhost<br>dbuname=$dbuname";
        while($myrow = mysql_fetch_array($result))
        {
            $details = '<?xml version="1.0" encoding="utf-8" ?>
                    <rss version="2.0">
                        <channel>
                            <title>'. $myrow['title'] .'</title>
                            <link>'. $myrow['link'] .'</link>
                            <description>'. $myrow['description']
.'</description>
                            <language>'. $myrow['language'] .'</language>
                            <image>
                                <title>'. $myrow['image_title'] .'</title>
                                <url>'. $myrow['image_url'] .'</url>
                                <link>'. $myrow['image_link'] .'</link>
                                <width>'. $myrow['image_width'] .'</width>
                                <height>'. $myrow['image_height']
.'</height>
                            </image>';
        }
        return $details;
    }
    
    function getItems()
    {
        $itemsTable = "webref_rss_items";
        $query = "SELECT * FROM ". $itemsTable;
        $db = mysql_connect($dbhost, $dbuname, $dbpass);
        mysql_select_db($dbname,$db);
        $result = mysql_query ($query, $db);
        $items = '';
        while($myrow = mysql_fetch_array($result))
        {
            $items .= '<item>
                         <title>'. $myrow["title"] .'</title>
                         <link>'. $myrow["link"] .'</link>
                         <description><![CDATA['. $myrow["description"]
.']]></description>
                     </item>';
        }
        $items .= '</channel>
                 </rss>';
        return $items;
    }

}

    $rss = new RSS();
    echo $rss->GetFeed();
?>
|

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux