Jump to content

Invalid argument supplied for foreach() suddenly appeared


unxposed

Recommended Posts

Helllllp!

 

My website www.unxposed.net has been up for a few months now, and everything has been fine.

 

This morning I opened up my browser, up came my page and I had the following 3 warnings at the top of the page:

Warning: Invalid argument supplied for foreach() in /home/sites/unxposed.net/public_html/index.php on line 42

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/sites/unxposed.net/public_html/index.php:42) in /home/sites/unxposed.net/public_html/includes/header.inc.php on line 5

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/sites/unxposed.net/public_html/index.php:42) in /home/sites/unxposed.net/public_html/includes/header.inc.php on line 5

 

Where have these come from? I haven't changed anything? Is this an issue created by my host?

 

I only know limited php, but here's the foreach bit on line 42. The actual site still looks fine (in firefox - not in explorer) and everything seems to be in order. All other pages are fine, just my home page.

 

foreach ($feed->get_items(0, 1) as $item) {

 

$data = '';

 

$data .= $item->get_date('U') . ':::::';

 

$data .= gmdate('d M y | H:i', $item->get_date('U')) . ':::::';

 

$data .= strip_tags($item->get_title()) . ':::::';

 

$data .= $item->get_permalink() . ':::::';

 

$data .= strip_tags($item->get_description()) . ':::::';

 

$data .= strip_tags($feed->get_feed_title()) . ':::::';

 

$data .= $feed->get_feed_link();

 

$multifeeds[] = $data;

}

 

Any ideas?

 

Thanks thanks thanks.

keep check

 

if(isset($feed->get_items(0, 1)  and is_array($feed->get_items(0, 1)))){

foreach ($feed->get_items(0, 1) as $item) {

 

      $data = '';

 

      $data .= $item->get_date('U') . ':::::';

 

      $data .= gmdate('d M y | H:i', $item->get_date('U')) . ':::::';

 

      $data .= strip_tags($item->get_title()) . ':::::';

 

      $data .= $item->get_permalink() . ':::::';

 

      $data .= strip_tags($item->get_description()) . ':::::';

 

      $data .= strip_tags($feed->get_feed_title()) . ':::::';

 

      $data .= $feed->get_feed_link();

 

      $multifeeds[] = $data;

   }

 

 

 

}else{

        //Handle else condition with msg or some thing else

}

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.