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

 

Link to comment
Share on other sites

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 
            }
            ?>

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

 

 

 

Link to comment
Share on other sites

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/

 

 

Link to comment
Share on other sites

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

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.