Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-01-2005, 05:39 AM RSS and mysql
Novice Talker

Posts: 5
Location: Brussels
Trades: 0
Hi all,

I'm facing a problem that I can't find a solution. I'm trying to creat a rss feed from a mysql table, the query I use in phpmyadmin is correct as I have the result I want but I can't call them, for some reason, in my php file. Here is the file

Code:
<?

header("Content-Type: text/xml; charset=utf-8");

// retrieve database records
include('conf/db.php');


if (!$db)
{
   error_log("Error: Could not connect to database");
   exit;
}


mysql_select_db("mydatabase");

$query1 = "select nomsite, url, description, date  from annuaire_sites where valid='1' order by date limit 10";
$result1 = mysql_query($query1);

// display RSS 2.0 channel information

ECHO <<<END
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
   <channel>
      <title>My title</title>
      <link>My link</link>
      <description>My description</description>
      <language>en-us</language>
      <generator>My generator</generator>
END;

for ($i = 0; $i < mysql_num_rows($result1); $i++) {
   @$row = mysql_fetch_array($result1);
   $title = $row["nomsite"];
   $link = $row["url"];
   $description = $row["description"];
   $date = $row["date"];

// display an item
ECHO <<<END

      <item>
         <title>$title</title>
         <link>$link</link>
         <description>$description</description>
         <date>$date</date>
      </item>
END;

}

ECHO <<<END

   </channel>
</rss>
END;

?>
I'm fairly new into php/mysql/rss so I don't understand everything but with my limited knowledge it seems, for me, it's right and I only get as result <html><body/></html> which doesn't make sense.

Can anybody please help me out ?

Many thanks
__________________

Please login or register to view this content. Registration is FREE
Valhala is offline
Reply With Quote
View Public Profile Visit Valhala's homepage!
 
 
Register now for full access!
Reply     « Reply to RSS and mysql
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11682 seconds with 12 queries