Code works on localhost but not live server

Im trying to use SimplePie to display recent news items in an HTML page. I got it working on my localhost but when i transfer it to my live server i just get a blank area where the items should be… im a novice PHP guy and am lost.:blush:

Here is the code im using- hopefully someone can point me in the right direction. please note that the “rss link goes here” part is because i cant post links.


<?php

// Make sure SimplePie is included. You may need to change this to match the location of simplepie.inc.
require_once('rss/simplepie.inc');

// We'll process this feed with all of the default options.
$feed = new SimplePie('rss feed link goes here');

// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();

// default starting item
$start = 0;

// default number of items to display. 0 = all
$length = 5;


?>
<?php
foreach ($feed->get_items($start,$length) as $item)
{
		$feed = $item->get_feed();
		
		echo '<h4><a href="' . $item->get_permalink() . '" target="_blank">' . $item->get_title() . '</a></h4>';
		echo '<p>' . $item->get_description() . '</p>';
		echo '<p>' . $item->get_date() . '</p>';
		
}
?>

is SimplePie installed on the live server?

EDIT: apparently it is just an include file hmm, is it being linked to correctly?

Yes- its just an include file (simplepie.inc) that i had to upload. I have it in a directory called rss and have the script pointing to the correct place.

rss feed link correct?

yeah- everything works on my localhost, feed displays, format is good, links work etc. but when i upload the same files to the live server its just blank. nothing there at all. i even added some HTML comments above and below the PHP to make sure the server was reading the newest file- when i check the source of the live page i see the HTML comments i added but still no feed items.

Add the below code to the top of your script. (Or see if any log files where made beside the php file.)


ini_set( 'display_errors', 1 ); 
 error_reporting( E_ALL );

It was not. I just added it, tested locally and then uploaded to live server. no errors displayed, same blank area.

write:

echo “hello world”;

at different points in your code.
first try it at the end of your code.
test it.
if there’s no hello world in your page, then move the line up in the code until it is at the beginning.

then you’ll be able to know where the code stops working.

that’s debugging for people who don’t use a php interpretor/debugger on their workstation.

Okay- after adding echo “hello world” above and below the foreach loop i get the “hello world” twice on the page. So im not getting any errors but im also not getting an feed info?

So it means that
$feed = new SimplePie(‘rss feed link goes here’);

returns an empty feed.

it means there’s an issue with the rss feed link on your live server, I don’t know why, but try a local file instead of an url.

SimplePie may be using something that the server doesn’t have, like SimpleXML or similar

could also be cUrl

make a file with

<?php info(); ?>

in it and run on both and compare what each has

fixed… sort of. there was nothing wrong to start with!

Thanks to craqgerbil for suggesting to check the PHPinfo. I knew it was fine but it made me think of the server and then i realized that this site was hosted by Godaddy and NOT on my server! The problem was that Godaddy was still running PHP4 and the cache folder settings were not writable. Doh! I am not a fan of godaddy.

Changed the godddy hosting account to PHP5 and CHMOD the cache folder to 777 and BAM, it works… just like my localhost. :slight_smile:

Thanks guys!!!