RSS Reader Not Working!

Post here is you are having problems with any of the tutorials.
Post Reply
ast020
Posts: 2
Joined: Thu Mar 28, 2013 8:49 pm

RSS Reader Not Working!

Post by ast020 »

I am trying to design a website similar to drudge report which posts dynamic rss feeds including images and titles. I think php is the best way to go. I am following the PHP Tutorial videos and I am stuck at the most basic part!! This is being hosted on a linux godaddy server.

File Structure:
/news.php
/core/init.inc.php
/core/inc/bbc_news_reader.inc.php

When I load news.php I get the following errors:

Warning: include(./inc/bbc_news_reader.inc.php) [function.include]: failed to open stream: No such file or directory in /home/content/74/********/html/core/init.inc.php on line 5

Warning: include() [function.include]: Failed opening './inc/bbc_news_reader.inc.php' for inclusion (include_path='.:/usr/local/php5_3/lib/php') in /home/content/74/********/html/core/init.inc.php on line 5

Fatal error: Call to undefined function fetch_news() in /home/content/74/********/html/news.php on line 18

Here is my Code:

news.php
<?php

include('core/init.inc.php');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php

fetch_news();

?>
</body>
</html>

init.inc.php
<?php

$path = dirname(_FILE_);

include("{$path}/inc/bbc_news_reader.inc.php");

?>
bbc_news_reader.inc.php
<?php

// http://feeds.bbci.co.uk/news/rss.xml

function fetch_news(){
	$data = file_get_contents('http://feeds.bbci.co.uk/news/rss.xml');
	
	echo $data;
}

?>
What am I doing wrong??
ast020
Posts: 2
Joined: Thu Mar 28, 2013 8:49 pm

Re: RSS Reader Not Working!

Post by ast020 »

SOLVED

For those who end up in my situation I discovered a major error in my code:

_FILE_ needs (2) underscores... __FILE__
<?php
 
$path = dirname(_FILE_);  **<--- Using (__FILE__) fixed this**
 
include("{$path}/inc/bbc_news_reader.inc.php");
 
?>
Post Reply