ya encontre la solucion
Código PHP:
<?php require_once('../Connections/conexionseimpex.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO subcategoria (Nombre_subcat) VALUES (%s)",
GetSQLValueString($_POST['Nombre_subcat'], "text"));
mysql_select_db($database_conexionseimpex, $conexionseimpex);
$Result1 = mysql_query($insertSQL, $conexionseimpex) or die(mysql_error());
$cod_subcategoria = mysql_query("SELECT MAX(id_subcat)id_subcat FROM subcategoria");
$resultado = mysql_fetch_array($cod_subcategoria);
$num = $resultado["id_subcat"];
$num2=GetSQLValueString($_POST['id_cat'], "int");
$query1 ="INSERT INTO categoria_subcategoria SET categoria_subcategoria.id_cat='$num2',categoria_subcategoria.id_subcat='$num'";
mysql_select_db($database_conexionseimpex, $conexionseimpex);
$Result2 = mysql_query($query1, $conexionseimpex) or die(mysql_error());
$insertGoTo = "subcategorias_lista.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conexionseimpex, $conexionseimpex);
$query_ConsultaCategorias = "SELECT * FROM categoria ORDER BY categoria.Nombre_cat ASC";
$ConsultaCategorias = mysql_query($query_ConsultaCategorias, $conexionseimpex) or die(mysql_error());
$row_ConsultaCategorias = mysql_fetch_assoc($ConsultaCategorias);
$totalRows_ConsultaCategorias = mysql_num_rows($ConsultaCategorias);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/BaseAdmin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Administración Seimpex C.A</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<link href="../estilo/twoColFixLtHdr.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="header"><img src="../images/logo.jpg" width="318" height="65" alt="Administracion" />
</div>
<div class="sidebar1">
<?php include("../includes/cabeceraadmin.php");
?>
<!-- end .sidebar1 --></div>
<div class="content"><!-- InstanceBeginEditable name="Contenido" -->
<h1>Añadir Subcategoria</h1>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td width="86" align="right" nowrap="nowrap">Nombre:</td>
<td width="259"><span id="sprytextfield1">
<input type="text" name="Nombre_subcat" value="" size="32" />
<span class="textfieldRequiredMsg">Necesario.</span></span>
*</td>
</tr>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Categoria:</td>
<td><label for="id_cat"></label>
<select name="id_cat" id="id_cat">
<?php
do {
?>
<option value="<?php echo $row_ConsultaCategorias['id_cat']?>"><?php echo $row_ConsultaCategorias['Nombre_cat']?></option>
<?php
} while ($row_ConsultaCategorias = mysql_fetch_assoc($ConsultaCategorias));
$rows = mysql_num_rows($ConsultaCategorias);
if($rows > 0) {
mysql_data_seek($ConsultaCategorias, 0);
$row_ConsultaCategorias = mysql_fetch_assoc($ConsultaCategorias);
}
?>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insertar Subcategoria" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
</script>
<!-- InstanceEndEditable -->
<!-- end .content --></div>
<div class="footer">
<p>Administración Página Seimpex C.A</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($ConsultaCategorias);
?>