When executed, The echo statements in this code reveal that the array is successfully loaded and the data is all where it should be. (when the insert and delete parts are commented out)
This routine is supposed to be an include that just formats the order data and adds it to the ORDERS table and then, if there was no error, deletes the old data from the CART table.
I have pored through the WROX book and the Visual guide to PHP to no avail. They don't tell me what rule(s) I am violating. I have commented out the insert and delete statements and the rest of it runs.
Code: Select all
<?php
for($counter=1; $counter<=$totalRows; $counter++)
{
echo " - " . $usernum[$counter]; //numeric
echo " - " . $user[$counter]; //alpha
echo " - " . $line_num[$counter]; //numeric
echo " - " . $part_num[$counter]; //alpha
echo " - " . $e_desc[$counter]; //alpha
echo " - " . $j_desc[$counter]; //alpha
echo " - " . $line_price[$counter]; //numeric
echo " - " . $quantity[$counter]; //numeric
echo " - " . $line_total[$counter]; //numeric
echo " - CARTID# -" . $cart_id_num[$counter]; //numeric
echo " - " . $prod_id_index[$counter]; //numeric
//The following lines insert the line data into the orders table
$query = "INSERT INTO orders VALUES('$usernum[$counter]','$user[$counter]',NULL,'$line_num[$counter]','$part_num[$counter]','$e_desc[$counter]','$j_desc[$counter]','$line_price[$counter]','$quantity[$counter]','$line_total[$counter]','New','New',NULL,'Standard Air',curdate(),NULL,NULL,'0','0')";
$result = mysql_query($query);
if(!$result) {
error_message(sql_error());
$error_text="ERROR - Add_Record_To_Order failed. Contact Customer Service";
echo $error_text;
}
//The following lines remove the item from cart only if the above add to order is successful.
if !error_text {
$query_cart_del = "DELETE FROM cart WHERE cart_id_num = $cart_id_num[$counter]";
$result_cart_del = mysql_query($query_cart_del);
if(!$result_cart_del) {
error_message(sql_error());
$error_text = "ERROR - Delete_From_Cart failed. Contact Customer Service";
echo $error_text;
}
}
}
?>Thanks for any help
------------------------------------
SteedVLX
I know my code is amateurish, Because that's what I am