Version: PHP4

Type: Sample Code (HOWTO)

Category: Shopping Carts

License: Other

Description: I am trying to make an ecommerce site and in addtobasket file I put following code to read the Quantities of the product but it keep sending this warning. I used same code 2 years back on PHP3 at that time it works but now its saying Warning: Variable passed to each() is not an array or object



$result = mysql ($conn, "SELECT PRODUCT_ID, QUANTITY FROM table_basket");

		while (list ($key, $value)= each ($QUANTITY) ) 
		{ 			
			if ($value == 0) continue;
			$query = "DELETE FROM $table_basket WHERE PRODUCT_ID = $key AND CUSTOMERID = $CustomerId";
			$result=mysql_query($query);
			if (! $result) printf ("Error: %s<br>", mysql_error ());
			$query = "INSERT INTO $table_basket SET PRODUCT_ID = $key, QUANTITY = $value, CUSTOMERID = $CustomerId";
			$result=mysql_query($query);
			if (! $result) printf ("Error: %s<br>", mysql_error ());
		};