I have been putting together a database of RSS feeds using Magpie,
Currently i have a list of feeds stored in a table which i can call and use to parse and write to another table which is to be referenced at a later date.
The problem i am encountering is that as the php script is to be loaded on a schedule it creates duplicate entries with in the database.
Below is the attached script:
$query = "SELECT URL,Category FROM feed_list";
$result = mysql_query($query);
while(list($url,$category) = mysql_fetch_row($result))
$rss = fetch_rss ( $url );
foreach ($rss->items as $item)
$href = $item;
$title = $item;
mysql_query("INSERT INTO feeds (Title, URL, Category) VALUES('$title','$url','$category')");
Does anybody have any suggestions on how to accomplish limiting the creation of new records based upon the url or the title of the RSS entity?
Or any other possible methods to accomplish this task?
Make URL a unique index in your database, then use INSERT IGNORE instead of just INSERT.
IGNORE tells MySQL to skip (ignore) any inserts that duplicate an existing unique index. Since the URL should always be unique, this method will work.
Log in to post a comment.