Bastien,
Got it all in, but the info in the array (or not) is not being written to the db columm.
I've got the col named 'numOpt', any idea what I am doing wrong? It also won't submit anything at all if I leave that first field checker 'if' statement in - but I've been cutting it out to test the submit. I am sure I've got all my fields named correctly.
<?
require_once("sc_fns.php");
if ($POST['catid'] == "" or $POST['prod_name'] == "" or $POST['prod_num'] == "" or $POST['prod_price'] == "" or $POST['ship_one'] == "" or $POST['tax_exempt'] == "" or $POST['ship_two'] == "" or $POST['decl_bal'] == "" or $POST['ship_three'] == "" or $POST['curr_inv'] == "" or $POST['ship_weight'] == "" or $POST['special'] == "" or $POST['max_qty_purchase'] == "" or $POST['lg_image'] == "" or $POST['max_qty_purch'] == "" or $POST['sm_image'] == "" or $POST['prod_options[]'] == "" or $POST['rel_prods'] == "" or $POST['prod_description'] == "" or $POST['add_email_confirm'] == "")
{
admin_header();
echo "<FONT FACE='ARIAL' SIZE='1' COLOR='FF0000'><BR>Error. You did not complete the entire form.<BR>You must enter information for each field to enter your product.<BR>Please try again, thank you.<BR></FONT>";
display_product_form();
do_html_footer();
exit;
}
$POST['catid'] = addslashes($POST['catid']);
$POST['prod_name'] = addslashes($POST['prod_name']);
$POST['prod_num'] = addslashes($POST['prod_num']);
$POST['prod_price'] = addslashes($POST['prod_price']);
$POST['ship_one'] = addslashes($POST['ship_one']);
$POST['tax_exempt'] = addslashes($POST['tax_exempt']);
$POST['ship_two'] = addslashes($POST['ship_two']);
$POST['decl_bal'] = addslashes($POST['decl_bal']);
$POST['ship_three'] = addslashes($POST['ship_three']);
$POST['curr_inv'] = addslashes($POST['curr_inv']);
$POST['ship_weight'] = addslashes($POST['ship_weight']);
$POST['special'] = addslashes($POST['special']);
$POST['max_qty_purchase'] = addslashes($POST['max_qty_purchase']);
$POST['lg_image'] = addslashes($POST['lg_image']);
$POST['max_qty_purch'] = addslashes($POST['max_qty_purch']);
$POST['sm_image'] = addslashes($POST['sm_image']);
$POST['prod_options[]'] = addslashes($POST['prod_options[]']);
$POST['rel_prods'] = addslashes($POST['rel_prods']);
$POST['prod_description'] = addslashes($POST['prod_description']);
$POST['add_email_confirm'] = addslashes($POST['add_email_confirm']);
//count the options choosen to see if you need to implode the
//array to be able to pass it to the DB. I found not imploding the
//array did not work as a valid DB entry.
$numOpts = count($prod_options);
//if the number of options choosen is more than 1, implode
if ($numOpts>1){
$myOpts=implode(",",$prod_options);
//if the number of options = 1, then everything okay as it is not
//an array
}elseif ($numOpts==1){
$myOpts=$prod_options;
//assign an empty string value to the options variable for DB entry
}else{
$myOpts="";
}
db_connct();
mysql_select_db("book_sc");
$query = "INSERT INTO products values ('".$POST['catid']."', '".$POST['prod_name']."', '".$POST['prod_num']."', '".$POST['prod_price']."', '".$POST['ship_one']."', '".$POST['tax_exempt']."', '".$POST['ship_two']."', '".$POST['decl_bal']."', '".$POST['ship_three']."', '".$POST['curr_inv']."', '".$POST['ship_weight']."', '".$POST['special']."', '".$POST['max_qty_purchase']."', '".$POST['lg_image']."', '".$POST['max_qty_purch']."', '".$POST['sm_image']."', '".$POST['numOpts']."', '".$POST['rel_prods']."', '".$POST['prod_description']."', '".$POST['add_email_confirm']."')";
$result = mysql_query($query);
if ($result)
admin_header();
echo "<FONT FACE='ARIAL' SIZE='1' COLOR='0000FF'><BR>Thank you. One new product has been entered into the cart database.</FONT>";
display_product_form();
do_html_footer();
?>
</body></html>