Jump to content

Warning: Invalid argument supplied for foreach()


MasterACE14

Recommended Posts

I have the following code:

if ( !empty($_GET['quantity']) ) {
foreach ( $_GET['quantity'] as $order_code => $quantity ) { // line 13
	$Cart->setItemQuantity($order_code, $quantity);
}
}

 

and I'm getting the following error:

Warning: Invalid argument supplied for foreach() in shopping-cart/cart_action.php on line 13

 

$_GET['quantity'];

has a value of '1'

 

The code is working perfectly fine on localhost, but throws me that warning on my webserver(both have error reporting set to E_ALL)

 

any help is greatly appreciated.

 

Thanks.

can you post your form code

		<form class="cart_form" action="plugins/shopping-cart/cart_action.php" method="get">
			<input type="hidden" name="order_code" value="Sword" />
			<label>Sword: <input class="center" type="text" name="quantity" value="1" size="3" /> </label>
                                <input type="hidden" name="TB_iframe" value="true" />
                                <input type="hidden" name="height" value="400" />
                                <input type="hidden" name="width" value="780" />
			<input type="submit" name="submit" value="Add to cart" />
		</form>

 

if $_GET['quantity'] has a value of '1' then its not an array type, which means that a foreach loop can't execute on it.

 

ok that makes sense, but why would it work locally and not on the webserver? they're both PHP 5? :S

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.