Jump to content

Invalid argument supplied for foreach


Yohanne

Recommended Posts

hello coders.

 

what is the possible reason why i get this warning:   Invalid argument supplied for foreach() in

 and i have no idea behind this code, but i know there is someone else can read this and understand behind the logic. 

$orders = Order::getOrdersWithInformations(10);
$i = 0;
foreach($orders AS $order)
{
      $currency = Currency::getCurrency((int)$order['id_currency']);
	echo '
	<tr'.($i % 2 ? ' id="order_line1"' : '').'>
	<td class="order_td_first order_id">'.(int)$order['id_order'].'</td>
	<td class="order_customer">'.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'</td>
	<td class="order_status">'.Tools::htmlentitiesUTF8($order['state_name']).'</td>
	<td class="order_total">'.Tools::displayPrice((float)$order['total_paid'], $currency).'</td>
	<td class="order_action">
	<a href="index.php?tab=AdminOrders&id_order='.(int)$order['id_order'].'&vieworder&token='.Tools::getAdminTokenLite('AdminOrders').'" title="'.$this->l('Details').'"><img src="../img/admin/details.gif" alt="'.$this->l('See').'" /></a>
			</td>
			</tr>
				';
			$i++;
		}
Link to comment
https://forums.phpfreaks.com/topic/279883-invalid-argument-supplied-for-foreach/
Share on other sites

If your not sure of the output of the result for getOrdersWithInformation() - wrap a conditional statement around your foreach, checking that the result of getOrdersWithInformation() is an array, so the foreach loop isn't instantiated and causing any errors if the result is false...

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.