Jump to content

Warning: Invalid argument supplied for foreach()


Sh4dowDan

Recommended Posts

I get this error:

Warning: Invalid argument supplied for foreach() in E:\xampp\htdocs\pages\file.php on line 269

269 line:

foreach ($announcements as $announcementsRow){

 

What is wrong with my .php file? could you please correct it?

///show news$announcements = $SQL->query("SELECT * FROM `announcements` WHERE id ORDER BY `date` DESC LIMIT 1");foreach ($announcements as $announcementsRow){$news_content .= '<div id="featuredarticle" class="Box"><div class="Corner-tl" style="background-image:url('.$layout_name.'/images/content/corner-tl.gif);"></div><div class="Corner-tr" style="background-image:url('.$layout_name.'/images/content/corner-tr.gif);"></div><div class="Border_1" style="background-image:url('.$layout_name.'/images/content/border-1.gif);"></div><div class="BorderTitleText" style="background-image:url('.$layout_name.'/images/content/title-background-green.gif);"></div><img class="Title" src="montaimg.php?text=Announcement" alt="Contentbox headline" /><div class="Border_2"><div class="Border_3"><div class="BoxContent" style="background-image:url('.$layout_name.'/images/content/scroll.gif);"><div id="TeaserThumbnail"><img src="images/news/announcement.jpg" width="150" height="100" border="0" alt="" /></div><div id="TeaserText"><div style="position: relative; margin-bottom: 2px;" ><div style="font-size:18px; font-weight:bold;">'.$announcementsRow['title'].'</div></div>'.$announcementsRow['text'].'<br /><br /><small style="float: right;">Posted by <font color="red">'.$announcementsRow['author'].'</font> - '.date("d M Y", $announcementsRow['date']).'</small>';if ($logged)if ($account_logged->getCustomField("page_access") > 6 ){ $news_content .='<input type="button" value="Deletar" OnClick="location.href=\'index.php?subtopic=cpanel&action=deletar_ann&id='.$announcementsRow['id'].'\'" />';} $news_content .='</div></div></div></div> <div class="Border_1" style="background-image:url('.$layout_name.'/images/content/border-1.gif);"></div><div class="CornerWrapper-b"><div class="Corner-bl" style="background-image:url('.$layout_name.'/images/content/corner-bl.gif);"></div></div><div class="CornerWrapper-b"><div class="Corner-br" style="background-image:url('.$layout_name.'/images/content/corner-br.gif);"></div></div></div>';} //

Where id is true (ie non=zero)

 

example

mysql> SELECT
    ->   id
    -> , username
    -> FROM users
    -> WHERE id
    -> ORDER BY status;
+----+----------+
| id | username |
+----+----------+
|  2 | User 222 |
|  4 | User 444 |
|  1 | User 111 |
|  3 | User 333 |
+----+----------+
4 rows in set (0.00 sec)

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.