Hey mrhappiness,
The insert is generated by Dreamweaver:
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($HTTP_SERVER_VARS['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO av_products (product_status, product_status_info, product_cat, product_model, product_jnumber, product_brand, product_title, product_description, product_features, product_dimensions, product_length, product_width, product_height, product_depth, product_weight, product_price, product_sale_price, product_added) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['product_status'], "text"),
GetSQLValueString($_POST['product_status_info'], "text"),
GetSQLValueString($_POST['product_cat'], "int"),
GetSQLValueString($_POST['product_model'], "text"),
GetSQLValueString($_POST['product_jnumber'], "text"),
GetSQLValueString($_POST['product_brand'], "int"),
GetSQLValueString($_POST['product_title'], "text"),
GetSQLValueString($_POST['product_description'], "text"),
GetSQLValueString($_POST['product_features'], "text"),
GetSQLValueString($_POST['product_dimensions'], "text"),
GetSQLValueString($_POST['product_length'], "text"),
GetSQLValueString($_POST['product_width'], "text"),
GetSQLValueString($_POST['product_height'], "text"),
GetSQLValueString($_POST['product_depth'], "text"),
GetSQLValueString($_POST['product_weight'], "text"),
GetSQLValueString($_POST['product_price'], "double"),
GetSQLValueString($_POST['product_sale_price'], "double"),
GetSQLValueString($_POST['product_added'], "date"));
mysql_select_db($database_AV_Store, $AV_Store);
$Result1 = mysql_query($insertSQL, $AV_Store) or die(mysql_error());
$insertGoTo = "/directory/webpage.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
Actually, this code contains NULL's. Is this insert telling the database to use NULLs if a form field is blank??
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
Thanks