totalphpnoob Posted June 6, 2008 Share Posted June 6, 2008 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 »</a></span>"; echo ‘</p>’; } } ?> Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/ Share on other sites More sharing options...
phpzone Posted June 6, 2008 Share Posted June 6, 2008 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 :-) Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559061 Share on other sites More sharing options...
bilis_money Posted June 6, 2008 Share Posted June 6, 2008 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 »</a></span>'; echo '</p>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559062 Share on other sites More sharing options...
totalphpnoob Posted June 6, 2008 Author Share Posted June 6, 2008 Hey Billis, It got that error knocked off, but I'm still getting an error: "Parse error: syntax error, unexpected T_STRING in /home/doj464/public_html/aboutresultsmarketing/incs/main.inc on line 18" Thanks for the help Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559065 Share on other sites More sharing options...
phpzone Posted June 6, 2008 Share Posted June 6, 2008 You still have the strange quotes on line 18 date('Y-d-m'); I'd use a different editor. You're not using Word are you? Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559073 Share on other sites More sharing options...
totalphpnoob Posted June 6, 2008 Author Share Posted June 6, 2008 I'm using notepad... That worked, except there are alot of errors on that script. I'm gonna have to sift through it. Thanks, David Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559088 Share on other sites More sharing options...
phpzone Posted June 6, 2008 Share Posted June 6, 2008 I use Aptana with the PHP Plugin. Worth a look. (Or Eclipse-PHP) I does syntax highlight as per usual for most editors, has intellisense and shows parse errors as you type. It would have easily picked up all the errors in your code. Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559177 Share on other sites More sharing options...
totalphpnoob Posted June 6, 2008 Author Share Posted June 6, 2008 Thanks for the tips, and helping a noob out Link to comment https://forums.phpfreaks.com/topic/108975-syntax-error-unexpected/#findComment-559204 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.