473,811 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RSS feeds with PHP and MySQL?

Does anyone have any good tutorials on how to create a dynamic RSS feed
that pulls data from a MySQL database using PHP? I found this one:
http://www.tiffanybbrown.com/article...article.php/66
....But I haven't quite been able to get it to work.

Thanks.
--ZenBug

Sep 6 '05 #1
4 1415
On 2005-09-06, Zenbug <ze****@gmail.c om> wrote:
Does anyone have any good tutorials on how to create a dynamic RSS feed
that pulls data from a MySQL database using PHP? I found this one:
http://www.tiffanybbrown.com/article...article.php/66
...But I haven't quite been able to get it to work.


At first sight, the article seems pretty clear.
Might want to tell us where exactly you are having problems...

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
Sep 6 '05 #2
Okay -- I wanted to be sure the question was appropriate for this group
first...

Essentially, I've had to modify the code in order to get any results
When I view my generated RSS feed in an RSS reader, I see a series of
items that are all titled "No Title", and they all contain no content.
I do know that it must be connecting to the database in some way,
because there are as many RSS items as there are news items in my
database. So I guess it's having a problem pulling out actual field
values.

Thanks for the help.
Here's my code as it is now:

<?
header('Content-type: text/xml');
?>

<rss version="2.0">
<channel>
<title>My title</title>
<description> My description</description>
<link>www.mysit e.com</link>
<copyright>copy right information</copyright>

<?
$dbh=mysql_conn ect ("localhost" , "user", "pass") or die ('I cannot
connect to the database because: ' . mysql_error());
mysql_select_db ("myDatabase ");

$getItems="SELE CT id, title, news FROM news ORDER BY id DESC";
$doGet=mysql_qu ery($getItems);

while($item=mys ql_fetch_array( $doGet))
{
$id=$doGet['id'];
$title=($doGet['title']);
$news=($doGet['news']);
?>

<item>
<title><?prin t $title;?></title>
<description><? print $news;?></description>
<link>http://www.littlepilgr ims.ca/</link>
</item>

<? } ?>
</channel>
</rss>

Sep 6 '05 #3
Zenbug (ze****@gmail.c om) wrote:
: Okay -- I wanted to be sure the question was appropriate for this group
: first...

: Essentially, I've had to modify the code in order to get any results
: When I view my generated RSS feed in an RSS reader, I see a series of
: items that are all titled "No Title", and they all contain no content.
: I do know that it must be connecting to the database in some way,
: because there are as many RSS items as there are news items in my
: database. So I guess it's having a problem pulling out actual field
: values.

: Thanks for the help.
: Here's my code as it is now:

: <?
: header('Content-type: text/xml');
: ?>

: <rss version="2.0">
: <channel>
: <title>My title</title>
: <description> My description</description>
: <link>www.mysit e.com</link>
: <copyright>copy right information</copyright>

: <?
: $dbh=mysql_conn ect ("localhost" , "user", "pass") or die ('I cannot
: connect to the database because: ' . mysql_error());
: mysql_select_db ("myDatabase ");

: $getItems="SELE CT id, title, news FROM news ORDER BY id DESC";
: $doGet=mysql_qu ery($getItems);

: while($item=mys ql_fetch_array( $doGet))
: {
: $id=$doGet['id'];
^^^^^^
: $title=($doGet['title']);
: $news=($doGet['news']);
Surely that should be $id=$item['id'], $title=$item['title'], etc.
^^^^^ ^^^^^

Off topic, but I think that <?php tags are prefered. All php servers
suport them, whereas <? only works on some servers, so it's a best habit
to simply use <?php and be done with it.

--

This programmer available for rent.
Sep 6 '05 #4
You're right; there was an error in the tutorial. Seems to be working
now.
Thanks again everyone!
--ZenBug
Malcolm Dew-Jones wrote:
Zenbug (ze****@gmail.c om) wrote:
: Okay -- I wanted to be sure the question was appropriate for this group
: first...

: Essentially, I've had to modify the code in order to get any results
: When I view my generated RSS feed in an RSS reader, I see a series of
: items that are all titled "No Title", and they all contain no content.
: I do know that it must be connecting to the database in some way,
: because there are as many RSS items as there are news items in my
: database. So I guess it's having a problem pulling out actual field
: values.

: Thanks for the help.
: Here's my code as it is now:

: <?
: header('Content-type: text/xml');
: ?>

: <rss version="2.0">
: <channel>
: <title>My title</title>
: <description> My description</description>
: <link>www.mysit e.com</link>
: <copyright>copy right information</copyright>

: <?
: $dbh=mysql_conn ect ("localhost" , "user", "pass") or die ('I cannot
: connect to the database because: ' . mysql_error());
: mysql_select_db ("myDatabase ");

: $getItems="SELE CT id, title, news FROM news ORDER BY id DESC";
: $doGet=mysql_qu ery($getItems);

: while($item=mys ql_fetch_array( $doGet))
: {
: $id=$doGet['id'];
^^^^^^
: $title=($doGet['title']);
: $news=($doGet['news']);
Surely that should be $id=$item['id'], $title=$item['title'], etc.
^^^^^ ^^^^^

Off topic, but I think that <?php tags are prefered. All php servers
suport them, whereas <? only works on some servers, so it's a best habit
to simply use <?php and be done with it.

--

This programmer available for rent.


Sep 7 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1561
by: J Sharman | last post by:
I am looking for a simple script will take an xml feed from a URL, then upload the information to mysql database. Any ideas Please reply to group and joe@joesharman.co.uk Regards
2
2236
by: the_ainbinders | last post by:
Anything like this around anywhere? Need to be able to input RSS information for several feeds and have it create an OMPL file. TIA, Rob
6
1509
by: plazma_41 | last post by:
Are there any uses for rss feeds on commercial websites selling products/services? Yes! I've just realized that eMaximarket Auctions ( http://www.emaximarket.com ) provides RSS feeds. For example, if you want to keep track of Art items for sale, you can use this feed:
5
1916
by: Mike Mella | last post by:
If I make an RSS feed of my site, am I expected to build and later update the RSS (XML) data by hand as I would any other webpage, or is there some process by which updates to a site are automatically incorporated into the RSS feed once the site itself is updated? Thanks. --Mella
1
1716
by: richards1052 | last post by:
I am setting up a forum website at which I plan to set up a news aggregator to pick up news headlines about the Mideast. But I've only been able to find a few news resources that have specific Mideast feeds (BBC, Haaretz, WashPo). I've tried looking up other publications at syndic8 & not succeeding in locating more feeds. I'd like to use such feeds from sources like the NY Times, Guardian, LA Times & others. Would anyone have ideas...
0
1212
by: jmwatte | last post by:
OK... 2 RSS feeds ... "http://feeds.feedburner.com/brainyquote/QUOTENA" "http://feeds.feedburner.com/qotd" Now I build a RSS reader in C#Express(did several of them including the starterkit) the "http://feeds.feedburner.com/brainyquote/QUOTENA" I can read the "http://feeds.feedburner.com/qotd" I can not... BUT in Beta 7 it's the other way around...
2
1547
by: dkode | last post by:
I built an asp.net usercontrol that consumes rss feeds that I specify the url for. Some of them (MVP blogs, google news) consumes the feeds just fine. and other times (75%) it chokes on stream.length and stream.position with an Exception of type System.NotSupportException. It seems as if with some RSS feeds, they are not formatted correctly? What can I do to get these to work properly.
5
2151
by: Shawn | last post by:
Hi, I want to understand and follow RSS feed because many web pages provide RSS feed for updated new data(e.g. http://www.weather.gov/rss/). But I never get how to use it. The link below suppose explains everything and how to use it. http://www.firstgov.gov/Topics/Reference_Shelf/Libraries/RSS_Library/What_Is_RSS.shtml except: How Do I Use RSS Feeds?
1
1885
by: Rama Jayapal | last post by:
hi i am developing a web application where i have to read multiple XML feeds amd store their values to database but i require the same type of fields from multiple XML feeds like for example
0
9727
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.