Jump to content

Warning: Invalid argument supplied for foreach() in


anthonyp01

Recommended Posts

 

Hello guys! This is my first post and hopefully you can help me!

 

I am trying to embed my blog into my website and the following code works below on a tempory server but when i run it on my paid server is get this error

 

Warning: Invalid argument supplied for foreach() in

 

Can anybody please help me.

 

		<?php 
            $rss = new lastRSS; 
            $rss->cache_dir = "_includes/rsscache/"; 
            $rss->cache_time = 7200;
            $rssout = $rss->get("http://myaccount.blogspot.com/feeds/posts/default?alt=rss");
            foreach($rssout['items'] as $item){
                $time = strtotime($item['pubDate']);

                ?>
                
                  <h3><?php echo $item['title'];?></h3>	
                    <div> 
                    <?php echo html_entity_decode($item['description']);?></div>
                    <h6><?php echo date("jS F Y",$time);?></h6>
                
            <?php 
            }
            ?>
            
            <?php

 

Many thanks for your help in advance.

 

Anthony

 

Hi Darkwarter,

 

I added that line as you requested but when running the page i get nothing, Just the same error.

 

I added the line here:

		<?php 
            $rss = new lastRSS; 
            $rss->cache_dir = "_includes/rsscache/"; 
            $rss->cache_time = 7200;
            $rssout = $rss->get("http://myaccount.blogspot.com/feeds/posts/default?alt=rss");
            print_r($rssout);
		foreach($rssout['items'] as $item){
                $time = strtotime($item['pubDate']);

                ?>
                
                  <h3><?php echo $item['title'];?></h3>	
                    <div> 
                    <?php echo html_entity_decode($item['description']);?></div>
                    <h6><?php echo date("jS F Y",$time);?></h6>
                
            <?php 
            }
            ?>

 

 

 

Nope,

 

Sorry but i'm not that great at php :( Im a graphic designer and flash programmer mainly.

 

This code worked on another server with no problems, just not on mine.

 

here is my test site im running it on blog is at the bottom

 

http://www.door15.co.uk/HTML/

 

i would put it in the same directory as your script, but change the extension from .phps to .php. then change the top of your code like so:

 

<?php
include("lastRSS.php");
$rss = new lastRSS; 
$rss->cache_dir = "_includes/rsscache/";

 

i assume the directory "_includes/rsscache/" exists and is writable. if not, you'll probably need it.

Bah!  :-[

 

It gets worse!

 

check this out:

 

http://door15.co.uk/HTML/

 

Why is doing that?

 

I added your line like this:

		<?php
		include("_includes/lastRSS.php");
		$rss = new lastRSS; 
            $rss->cache_dir = "_includes/rsscache/"; 
            $rss->cache_time = 7200;
            $rssout = $rss->get("http://door15design.blogspot.com/feeds/posts/default?alt=rss");
            print_r($rssout);
		foreach($rssout['items'] as $item){
                $time = strtotime($item['pubDate']);

                ?>
                
                  <h3><?php echo $item['title'];?></h3>	
                    <div> 
                    <?php echo html_entity_decode($item['description']);?></div>
                    <h6><?php echo date("jS F Y",$time);?></h6>
                
            <?php 
            }
            ?>

 

Are you sure i need lastRSS.php?

 

I have already added this to my file

<?php require("_includes/rss.php");
?>

 

Does that not do the same thing?

 

 

 

Yes ofc.

 

This is the code for the blog:

		<?php
		include("_includes/lastRSS.php");
		$rss = new lastRSS; 
            $rss->cache_dir = "_includes/rsscache/"; 
            $rss->cache_time = 7200;
            $rssout = $rss->get("http://door15design.blogspot.com/feeds/posts/default?alt=rss");
            print_r($rssout);
		foreach($rssout['items'] as $item){
                $time = strtotime($item['pubDate']);

                ?>
                
                  <h3><?php echo $item['title'];?></h3>	
                    <div> 
                    <?php echo html_entity_decode($item['description']);?></div>
                    <h6><?php echo date("jS F Y",$time);?></h6>
                
            <?php 
            }
            ?>

 

The include line is at the top.

 

But i have added rss.php at the top of the site:

<?php require("_includes/rss.php");
?>

 

do rss.php and lastRSS.php do similar things?

 

lastRSS.php is not installed on the other server yet the blog runs fine.

 

See here: http://www.clients.interdesigns.co.uk/Door15/

 

 

So basically this is my problem on the other server:

            <?php require("_includes/rss.php");
?>
            <?php
    $rss = new lastRSS; 
            $rss->cache_dir = "_includes/rsscache/"; 
            $rss->cache_time = 7200;
            $rssout = $rss->get("http://door15design.blogspot.com/feeds/posts/default?alt=rss");
            print_r($rssout);
		foreach($rssout['items'] as $item){
                $time = strtotime($item['pubDate']);

                ?>
                
                  <h3><?php echo $item['title'];?></h3>	
                    <div> 
                    <?php echo html_entity_decode($item['description']);?></div>
                    <h6><?php echo date("jS F Y",$time);?></h6>
                
            <?php 
            }
            ?>

 

This code works fine on the test server but not on my live server i get this error:

 

Warning: Invalid argument supplied for foreach() in /usr/local/home/httpd/vhtdocs/door15.co.uk/HTML/index.php on line 482

 

 

 

 

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.