CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
PHP Problems
Help with RSS feeds to email script
kolins
Permalink to comment
#
May 2009
Hi, I got this php script that is meant to get feeds from google blog search and send them to an email address:
<?php
$keyword = “keyword”;
$num = 5;
$feed = simplexml_load_file(”
http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&q=
” .urlencode($keyword). “&ie=utf-8&num=10&output=rss”);
foreach ($feed->channel->item as $item) {
if($i < $num){
sleep(10);
$title = $item->title;
$title = str_replace(”<b>”, “”, $title);
$subject = str_replace(”</b>”, “”, $title);
$link = $item->link;
$description = $item->description;
$description = str_replace(”<b>”, “”, $description);
$body = str_replace(”</b>”, “”, $description);
$to = “email address”;
$headers = ‘From:
mail@whatever.com
’;
if(mail($to, $subject, $body, $headers)) {
echo $subject. ” - sent<br>”;
}
else
{
echo $subject. ” - NOT sent<br>”;
}
}
$i++;
}
?>
But when I upload and run it through my browser, it outputs an error:
Parse error: syntax error, unexpected ':' on line 10
AshtonSanders
Permalink to comment
#
May 2009
What is on line 10 of the file?
Ashton Sanders
kolins
Permalink to comment
#
May 2009
It's just this whole script. There's no other file. I just got this script from a website.
apostrophe
Permalink to comment
#
May 2009
I take it you copied and pasted this script from a website?
You have some formatting issues, so you need to go through the script deleting and replacing all of the double and single quotes.
kolins
Permalink to comment
#
May 2009
Yes, I've already tried replacing "keyword" with "health" as I want to receive blogs on health issues, and "email address" with "myemail@yahoo.com" with same error result.
apostrophe
Permalink to comment
#
May 2009
You misunderstand.
Replace " and ' everywhere they appear in the script. They are being formatted as blockquotes and apostrophes.
kolins
Permalink to comment
#
May 2009
What should I replace them with? :?:
apostrophe
Permalink to comment
#
May 2009
Plain single quotes and double quotes.
kolins
Permalink to comment
#
May 2009
It works! For a long time I thought plain quotes and block quotes and apostrophes were the same. Thanks a lot. :D
Add a Comment
<?php
$keyword = “keyword”;
$num = 5;
$feed = simplexml_load_file(”http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&q=” .urlencode($keyword). “&ie=utf-8&num=10&output=rss”);
foreach ($feed->channel->item as $item) {
if($i < $num){
sleep(10);
$title = $item->title;
$title = str_replace(”<b>”, “”, $title);
$subject = str_replace(”</b>”, “”, $title);
$link = $item->link;
$description = $item->description;
$description = str_replace(”<b>”, “”, $description);
$body = str_replace(”</b>”, “”, $description);
$to = “email address”;
$headers = ‘From: mail@whatever.com’;
if(mail($to, $subject, $body, $headers)) {
echo $subject. ” - sent<br>”;
}
else
{
echo $subject. ” - NOT sent<br>”;
}
}
$i++;
}
?>
But when I upload and run it through my browser, it outputs an error:
Parse error: syntax error, unexpected ':' on line 10
Ashton Sanders
You have some formatting issues, so you need to go through the script deleting and replacing all of the double and single quotes.
Replace " and ' everywhere they appear in the script. They are being formatted as blockquotes and apostrophes.