The following script was running on a OS X machine running Apache 1.x and PHP 4.x. I just moved the script over to a Linux machine running Apache 2.0.51 and PHP 4.3.8, and now the foreach line does not work. It says Warning: Invalid argument supplied for foreach() in /var/www/localhost/htdocs/warehouse/whse_order_submit.php on line 39
Here is the script:
<?php
//get the variables from the other page
$id=$_POST['id_no'];
$sku=$_POST['sku'];
$description=$_POST['description'];
$order=($_POST['order_qty']);
$store=$_POST['store'];
$comment=$_POST['comment'];
$ip=$REMOTE_ADDR;
//check if store is empty
if(empty($store)) {
die("Store is required. Please press the back button and enter in your store.");
}
//connect to the database
require('../inc/database_conn.php');
//$month=getdate(mon);
//$day=getdate(mday);
//$year=getdate(year);
//$today=$year . "-" . $month . "-" . $day
$today=date('Y-m-d');
// create the unique order number
$headerqry = "INSERT INTO misc_order_header (order_date, store, comment, ip) VALUES ('$today', '$store', '$comment', '$ip')";
mysql_query($headerqry, $conn) or die(mysql_error());
$order_no=mysql_insert_id();
foreach($order_qty as $id_no => $val) {
if($order_qty[$id_no] > 0) {
$detailqry = "INSERT INTO misc_order_detail (order_no, id_no, sku, order_qty, order_date, store) VALUES ('$order_no', '$id_no', '$sku', '".$order_qty[$id_no]."', '$today', '$store')";
mysql_query($detailqry, $conn) or die(mysql_error() . "<BR>" . $detailqry);
}
}
Thanks for any help you can offer me.