WordPress.org

Ready to get started?Download WordPress

Forums

Can an PHP experts help? (4 posts)

  1. The Night Fox
    Member
    Posted 2 years ago #

    Ok so I'm trying to simply add some code to the Google news plugin so that all the results are nofollowed. I located the code where rel="nofollow" needs to be inserted, but my poor knowledge oh php means that no matter what I do I get an error!

    $result .= "<li>$description</li>";
                    } else {
                            $result .= "<li><a href=\"$link\" target=\"_blank\" ".
                                       "title=\"$tooltip\" "rel=\"nofollow\">$title<br>$related[1]</a></li>";
                    }
                }
                return $result.'</ul>';
            }

    I always get the error: Parse error: syntax error, unexpected T_STRING in /filepath/wp-content/plugins/google-news/google_news.php on line 747

    Can anyone help me fix this fairly simple problem?

  2. The Night Fox
    Member
    Posted 2 years ago #

    I have tried every possible permutation I can think of, but I keep getting the error. Any suggestions?

  3. yoozoo
    Member
    Posted 2 years ago #

    Hey, I may have a suggestion or two.

    Did you check line 747 to see which string is having trouble being parsed? I checked the unedited php and line 747 turns out to be:

    $result .= "<li><a href=\"$link\" target=\"_blank\" ".

    That string looks fine, as it is no different than the original, unedited code.

    However, line 747 in your php might vary from the unedited version. Especially because of a discrepancy in that the unedited php is arranged a bit differently than what you have posted (disregarding the addition of the nofollow value).

    $link = $item['link'];
                    if ( strlen($desctype) ) {
    
                         .= "<li>$description</li>";
                    } else {
                            $result .= "<li><a href=\"$link\" target=\"_blank\" ".
                                       "title=\"$tooltip\">$title<br />$related[1]</a></li>";
                    }
                }
                return $result.'</ul>';
            }

    Therein might lie the problem.

    I also noticed in your code

    "title=\"$tooltip\" "rel=\"nofollow\">$title<br>$related[1]</a></li>";

    that there are seven quotation marks. You should try removing the " before rel=

    Finding what string is on line 747 for you will help figure out why you're getting the error. Let me know what you find. I'll check in to see if I can help.

  4. The Night Fox
    Member
    Posted 2 years ago #

    Hi yoozoo, thanks for the help!

    You were right about there being too many quotation marks, as soon as I removed the quotation before rel everything was solved! I feel a little bit silly now for failing to notice it myself!

    Thanks again,

    TNF

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.