I have problems with my record insertion form. I have 2 tables Item and manfac and the form i have inserts values into the Item table and i have a manid field which is the link to the manfac table. in the manid field i got a menu that gets its values from the manfac table.
i can seem to insert values into the item table ok but the link is not working. this is first big php project and i have had trouble with this for bout a week. any help would be great.
the code for the adminadd.php (record insertion code) foloows:
<?php require_once('Connections/RecordStorePHP.php'); ?>
<?php
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 .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO item (ItemName, ManID, ItemRRP, ItemNOtes, ItemNumber, ItemAvailable, ItemCoverURL, ItemCoverThumbURL) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['ItemName'], "text"),
GetSQLValueString($HTTP_POST_VARS['ManID'], "int"),
GetSQLValueString($HTTP_POST_VARS['ItemRRP'], "int"),
GetSQLValueString($HTTP_POST_VARS['ItemNOtes'], "text"),
GetSQLValueString($HTTP_POST_VARS['ItemNumber'], "int"),
GetSQLValueString($HTTP_POST_VARS['ItemAvailable'], "int"),
GetSQLValueString($HTTP_POST_VARS['ItemCoverURL'], "text"),
GetSQLValueString($HTTP_POST_VARS['ItemCoverThumbURL'], "text"));
mysql_select_db($database_RecordStorePHP, $RecordStorePHP);
$Result1 = mysql_query($insertSQL, $RecordStorePHP) or die(mysql_error());
}
mysql_select_db($database_RecordStorePHP, $RecordStorePHP);
$query_ManfacRecordset1 = "SELECT * FROM manfac";
$ManfacRecordset1 = mysql_query($query_ManfacRecordset1, $RecordStorePHP) or die(mysql_error());
$row_ManfacRecordset1 = mysql_fetch_assoc($ManfacRecordset1);
$totalRows_ManfacRecordset1 = mysql_num_rows($ManfacRecordset1);
mysql_select_db($database_RecordStorePHP, $RecordStorePHP);
$query_Itemrecordset = "select * from item";
$Itemrecordset = mysql_query($query_Itemrecordset, $RecordStorePHP) or die(mysql_error());
$row_Itemrecordset = mysql_fetch_assoc($Itemrecordset);
$totalRows_Itemrecordset = mysql_num_rows($Itemrecordset);
?>
********** (html coding)
<!-- InstanceEnd --></html>
<?php
mysql_free_result($ManfacRecordset1);
mysql_free_result($Itemrecordset);
?>
would be great if anyone can help me, if u need any assistence please let me know. thanks