unxposed Posted May 7, 2007 Share Posted May 7, 2007 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. Link to comment https://forums.phpfreaks.com/topic/50338-invalid-argument-supplied-for-foreach-suddenly-appeared/ Share on other sites More sharing options...
jitesh Posted May 7, 2007 Share Posted May 7, 2007 Keep following code at line 41 echo "<pre>"; print_r($feed->get_items(0, 1)); // Check are you getting array or not ? Link to comment https://forums.phpfreaks.com/topic/50338-invalid-argument-supplied-for-foreach-suddenly-appeared/#findComment-247164 Share on other sites More sharing options...
unxposed Posted May 7, 2007 Author Share Posted May 7, 2007 Thanks, yep I did that. There's definately an array... I don't really understand the error. It's for the 'News from the front line!' which is working perfectly. Thanks again. Link to comment https://forums.phpfreaks.com/topic/50338-invalid-argument-supplied-for-foreach-suddenly-appeared/#findComment-247178 Share on other sites More sharing options...
unxposed Posted May 7, 2007 Author Share Posted May 7, 2007 Okay it suddenly dissapeared again... which is good. I'm just a bit worried that it might happen again. Anybody have any ideas why this might have happened? Thanks. Link to comment https://forums.phpfreaks.com/topic/50338-invalid-argument-supplied-for-foreach-suddenly-appeared/#findComment-247193 Share on other sites More sharing options...
jitesh Posted May 7, 2007 Share Posted May 7, 2007 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 } Link to comment https://forums.phpfreaks.com/topic/50338-invalid-argument-supplied-for-foreach-suddenly-appeared/#findComment-247196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.