Jump to content

syntax error, unexpected '>'


totalphpnoob

Recommended Posts

I'm really new to php, and I'm just learning how to code. I have a little script that is returning an error and I can't figure out the problem...

 

The error I get (you can see it at: www.aboutresultsmarketing.com) is:

 

Parse error: syntax error, unexpected '>' in /main.inc on line 23

 

The code is:

 

 <?php function print_rss($url,$count=2,$length=150) {
  require_once('magpierss/rss_fetch.inc');
  require_once('smart_trim.php');
  $rss = fetch_rss($url);
  foreach ($rss->items as $item) {
    if (++$cnt>$count) { break; }
    $href = $item['link'];
    $title = $item['title'];
    $published = strtotime($item['pubdate']);
    $content = strip_tags($item['content']['encoded']);
    $body = smart_trim($content, $length, false, ‘…’);
    echo ‘<p>’;
    echo ‘<span style="font-size: 80%;color:#9BB23B;">’;
    echo date(’F d, Y’, $published);
    echo ‘</span><br />’;
    echo "<a href=\"$href\">$title</a><br />";
    echo ‘<span style="font-size:80%;color:#666;">’;
    echo $body;
    echo "<br /><a href=\"$href\">More &#187;</a></span>";
    echo ‘</p>’;
  }
} ?>

Link to comment
https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/
Share on other sites

There appear to be strange Single Quotes in this code, did the forum do this?

 

When I try the code straight out, does not work, I get the error.

 

If I replace all the unusual single quotes with normal single quotes, no errors.

 

But, please see my one and only blog post at http://www.phpzone.co.uk :-)

try this my friend

 

<?php 

function print_rss($url,$count=2,$length=150) {
  require_once('magpierss/rss_fetch.inc');
  require_once('smart_trim.php');
  $rss = fetch_rss($url);
  foreach ($rss->items as $item) {
    if (++$cnt>$count) { 
		break; 
		}
    $href = $item['link'];
    $title = $item['title'];
    $published = strtotime($item['pubdate']);
    $content = strip_tags($item['content']['encoded']);
    $body = smart_trim($content, $length, false, '…');
    echo '<p>';
    echo '<span style="font-size: 80%;color:#9BB23B;">';
    echo date(’F d, Y’, $published);
    echo '</span><br />';
    echo '<a href=\"$href\">$title</a><br />';
    echo '<span style="font-size:80%;color:#666;">';
    echo $body;
    echo '<br /><a href=\"$href\">More &#187;</a></span>';
    echo '</p>';
  }
} 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.