All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Help with RSS feeds to email script

  • # May 6, 2009 at 11:39 am

    Hi, I got this php script that is meant to get feeds from google blog search and send them to an email address:


    $keyword = “keyword”;

    $num = 5;

    $feed = simplexml_load_file(”” .urlencode($keyword). “&ie=utf-8&num=10&output=rss”);

    foreach ($feed->channel->item as $item) {

    if($i < $num){


    $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:’;

    if(mail($to, $subject, $body, $headers)) {
    echo $subject. ” – sent<br>”;
    echo $subject. ” – NOT sent<br>”;




    But when I upload and run it through my browser, it outputs an error:

    Parse error: syntax error, unexpected ‘:’ on line 10

    # May 7, 2009 at 3:11 am

    What is on line 10 of the file?

    Ashton Sanders

    # May 7, 2009 at 5:49 am

    It’s just this whole script. There’s no other file. I just got this script from a website.

    # May 7, 2009 at 6:38 am

    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.

    # May 7, 2009 at 7:41 am

    Yes, I’ve already tried replacing "keyword" with "health" as I want to receive blogs on health issues, and "email address" with "" with same error result.

    # May 7, 2009 at 8:28 am

    You misunderstand.

    Replace " and ‘ everywhere they appear in the script. They are being formatted as blockquotes and apostrophes.

    # May 8, 2009 at 10:52 pm

    What should I replace them with? :?:

    # May 9, 2009 at 1:25 am

    Plain single quotes and double quotes.

    # May 10, 2009 at 4:43 am

    It works! For a long time I thought plain quotes and block quotes and apostrophes were the same. Thanks a lot. :D

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed