954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Post RSS feeds to MySQL

I am currently using a script to run RSS feeds and dump all data into a MySQL. Every time I run it, it creates a duplicate entry into a database. Is there any way, I can just program a script to only get new feeds?

I have some feeds subscribed on the microsoft outlook and it shows me new feeds as if its a new email. When outlook can handle such thing, I guess my script can handle it too.

s0bigg
Newbie Poster
23 posts since Aug 2011
Reputation Points: 10
Solved Threads: 1
 

Both RSS 2.0 and Atom use GUID and ID to identify unique items/entries inside the feed, use those values associated with each source to check what you have already included.

Bye :)

cereal
Master Poster
709 posts since Aug 2007
Reputation Points: 214
Solved Threads: 120
 

post the mysql insert part and we can probley help more

HITMANOF44th
Posting Whiz in Training
283 posts since Apr 2009
Reputation Points: 24
Solved Threads: 33
 
mysql_query("INSERT INTO data values('$title','$link','$description','$myDate')");


Thanks for your help!

s0bigg
Newbie Poster
23 posts since Aug 2011
Reputation Points: 10
Solved Threads: 1
 
// check db to see if the record is there
$sql="SELECT * FROM `data` WHERE (`title` = '$title' AND `description` = '$description') AND `date` = '$mydate' ";
$result=mysql_query($sql);
//count results
$count=mysql_num_rows($result);
if($count == 0){
//if record doesnt exist add it
mysql_query("INSERT INTO data values('$title','$link','$description','$myDate')");

}
HITMANOF44th
Posting Whiz in Training
283 posts since Apr 2009
Reputation Points: 24
Solved Threads: 33
 

also i dont know what your data looks like you might want to use
addslashes(); in case it has special characters

HITMANOF44th
Posting Whiz in Training
283 posts since Apr 2009
Reputation Points: 24
Solved Threads: 33
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: