/    Sign up×
Community /Pin to ProfileBookmark

this used to work, now all of the sudden it doesn’t. :(

a few months ago i found this code that puts some rss news headlines on my site. it used to work perfect! now all of the sudden, it does not do anything and i have not changed it! anyone know what’s going on? TIA. here is the code:

<?

// The @ is to supress the function´ errors

$newsfeed = ‘http://rss.news.yahoo.com/rss/business‘;

$fp = @fopen($newsfeed, ‘r’);
while(!feof($fp)){
$row .= @fgets($fp, 4096);
}
@fclose($fp);

if( eregi(‘<item>(.*)</item>’, $row, $rowitem ) ) {
$item = explode(‘<item>’, $rowitem[0]);

for( $i = 5; $i < count($item) – 1; $i++ ) {

eregi(‘<title>(.*)</title>’, $item[$i+1], $title );
eregi(‘<link>(.*
)</link>’, $item[$i+1], $link );
eregi(‘<pubDate>(.*)</pubDate>’, $item[$i+1], $pubDate);

echo ‘<table width=”468″ border=”0″ cellpadding=”3″ cellspacing=”0″ bgcolor=”#FFFFFF”><tr><td align=”center”><a href=”‘ . $link[1] . ‘” target=”_blank”><b>’ . $title[1] . ‘</b></a><br>’;
echo ” . $pubDate[1] . ‘</td></tr></table>’;

}
}

?>

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 16.2005 — Maybe short tags has been switched off on your server. Try starting with <?php
Copy linkTweet thisAlerts:
@NogDogAug 16.2005 — A few changes I'd try to see if you can narrow down where the problem is (my changes commented with "# <<"
[code=php]
<?php # << some configs require full php tag, so safest to always us it
error_reporting(E_ALL); # << for now have PHP report all errors
// The @ is to supress the function´ errors
# << if you're going to use @, then you'd best do your own error-checking

$newsfeed = 'http://rss.news.yahoo.com/rss/business';

$fp = @fopen($newsfeed, 'r') or die("fopen($newfeed) failed"); # << look for error
while(!feof($fp)){
$row .= @fgets($fp, 4096);
}
@fclose($fp);

if( eregi('<item>(.*)</item>', $row, $rowitem ) ) {
$item = explode('<item>', $rowitem[0]);

for( $i = 5; $i < count($item) - 1; $i++ ) {

eregi('<title>(.*)</title>', $item[$i+1], $title );
eregi('<link>(.*)</link>', $item[$i+1], $link );
eregi('<pubDate>(.*)</pubDate>', $item[$i+1], $pubDate);

echo '<table width="468" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF"><tr><td align="center"><a href="' . $link[1] . '" target="_blank"><b>' . $title[1] . '</b></a><br>';
echo '' . $pubDate[1] . '</td></tr></table>';

}
}

?>
[/code]
Copy linkTweet thisAlerts:
@Chaos343authorAug 16.2005 — i just tried using the code NogDog posted.

now it says: "Notice: Undefined variable: row on line 10"

line 10 is this:

$row .= fgets($fp, 4096);

i'm thinking something either changed with my server or the format of the yahoo rss feed, since it used to work and i didn't change anything.
Copy linkTweet thisAlerts:
@bokehAug 16.2005 — Change this:
[code=php]while(!feof($fp)){
$row .= @fgets($fp, 4096);
}
@fclose($fp);[/code]


to this:
[code=php]$row = '';
while(!feof($fp)){
$row .= @fgets($fp, 4096);
}
@fclose($fp);[/code]
×

Success!

Help @Chaos343 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...