Ver Mensaje Individual
  #6 (permalink)  
Antiguo 12/06/2009, 14:50
oscarozuna
 
Fecha de Ingreso: marzo-2009
Mensajes: 14
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: Problemas con require e insertar registro

y este es el que llamo con require()..


<?php require_once('Connections/slc_base.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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"] == "form_confirmar_registro")) {
$insertSQL = sprintf("INSERT INTO slc_registro_juegos (id_num, nombre_juego, version, tipo, plataforma, idioma, descripcion, obs) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ins_num_txt'], "int"),
GetSQLValueString($_POST['ins_nombre_txt'], "text"),
GetSQLValueString($_POST['ins_version_txt'], "text"),
GetSQLValueString($_POST['ins_tipo_txt'], "text"),
GetSQLValueString($_POST['ins_plataforma_txt'], "text"),
GetSQLValueString($_POST['ins_idioma_txt'], "text"),
GetSQLValueString($_POST['ins_descripcion_txt'], "text"),
GetSQLValueString($_POST['ins_obs_txt'], "text"));

mysql_select_db($database_slc_base, $slc_base);
$Result1 = mysql_query($insertSQL, $slc_base) or die(mysql_error());

$insertGoTo = "registro_exitoso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_slc_base, $slc_base);
$query_reg_tipo_juego = "SELECT * FROM slc_tipo_juego ORDER BY id_num ASC";
$reg_tipo_juego = mysql_query($query_reg_tipo_juego, $slc_base) or die(mysql_error());
$row_reg_tipo_juego = mysql_fetch_assoc($reg_tipo_juego);
$totalRows_reg_tipo_juego = mysql_num_rows($reg_tipo_juego);

mysql_select_db($database_slc_base, $slc_base);
$query_reg_plataforma = "SELECT * FROM slc_plataforma ORDER BY id_num ASC";
$reg_plataforma = mysql_query($query_reg_plataforma, $slc_base) or die(mysql_error());
$row_reg_plataforma = mysql_fetch_assoc($reg_plataforma);
$totalRows_reg_plataforma = mysql_num_rows($reg_plataforma);

mysql_select_db($database_slc_base, $slc_base);
$query_reg_idioma = "SELECT * FROM slc_idioma ORDER BY id_num ASC";
$reg_idioma = mysql_query($query_reg_idioma, $slc_base) or die(mysql_error());
$row_reg_idioma = mysql_fetch_assoc($reg_idioma);
$totalRows_reg_idioma = mysql_num_rows($reg_idioma);
<style type="text/css">
<!--
.Estilo1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: small;
}
.Estilo18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; }
.Estilo19 {font-size: small}
.Estilo20 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; }
.Estilo22 {color: #FFFF99}
-->
</style>
</head>


<?php //ACA HACEMOS UN DO WHILE PARA QUE NOS CREE LOS IF'S QUE VAMOS A NECESITAR PARA TOMAR EL VALOR DEL LISTBOX TIPO DE JUEGO
do {
if ($_POST['tipo_juego']==$row_reg_tipo_juego['id_num'])
{
$var_tipo_juego=$row_reg_tipo_juego['tipo_juego'];
}
} while ($row_reg_tipo_juego = mysql_fetch_assoc($reg_tipo_juego));
?>

<?php //ACA HACEMOS UN DO WHILE PARA QUE NOS CREE LOS IF'S QUE VAMOS A NECESITAR PARA TOMAR EL VALOR DEL LISTBOX PLATAFORMA
do {
if ($_POST['plataforma']==$row_reg_plataforma['id_num'])
{
$var_plataforma=$row_reg_plataforma['plataforma'];
}
} while ($row_reg_plataforma = mysql_fetch_assoc($reg_plataforma));
?>

<?php //ACA HACEMOS UN DO WHILE PARA QUE NOS CREE LOS IF'S QUE VAMOS A NECESITAR PARA TOMAR EL VALOR DEL LISTBOX IDIOMA
do {
if ($_POST['idioma']==$row_reg_idioma['id_num'])
{
$var_idioma=$row_reg_idioma['idioma'];
}
} while ($row_reg_idioma = mysql_fetch_assoc($reg_idioma));
?>




<body>
<table width="286" height="34" border="0" align="center">
<tr>
<td><form action="<?php echo $editFormAction; ?>" id="form_confirmar_registro" name="form_confirmar_registro" method="POST">
<table width="286" border="0" bgcolor="#FFFF99">
<tr>
<td width="9">&nbsp;</td>
<td colspan="2"><div align="center" class="Estilo1">CONFIRMAR DATOS</div></td>
<td width="10">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="83"><span class="Estilo19"></span></td>
<td width="170"><span class="Estilo19"></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Nombre: </div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['nombre_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Version:</div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['version_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Tipo:</div></td>
<td><span class="Estilo20"><strong><?php echo $var_tipo_juego; ?></strong></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Plataforma:</div></td>
<td><span class="Estilo20"><strong><?php echo $var_plataforma; ?></strong></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Idioma:</div></td>
<td><span class="Estilo20"><strong><?php echo $var_idioma; ?></strong></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Descripcion:</div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['descripcion_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Obs.:</div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['obs_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><span class="Estilo19"></span></td>
<td><span class="Estilo19">
<input name="ins_num_txt" type="hidden" id="ins_nombre_txt" value=" " />
<label>
<input name="ins_nombre_txt" type="hidden" id="ins_nombre_txt" value="<?php echo $_POST['nombre_txt'];?>" />
</label>
<label>
<input name="ins_version_txt" type="hidden" id="ins_version_txt" value="<?php echo $_POST['version_txt'];?>" />
</label>
<label>
<input name="ins_tipo_txt" type="hidden" id="ins_tipo_txt" value="<?php echo $var_tipo_juego; ?>" />
</label>
<label>
<input name="ins_plataforma_txt" type="hidden" id="ins_plataforma_txt" value="<?php echo $var_plataforma; ?>" />
</label>
<label>
<input name="ins_idioma_txt" type="hidden" id="ins_idioma_txt" value="<?php echo $var_idioma; ?>" />
</label>
<label>
<input name="ins_descripcion_txt" type="hidden" id="ins_descripcion_txt" value="<?php echo $_POST['descripcion_txt'];?>" />
</label>
<label>
<input name="ins_obs_txt" type="hidden" id="ins_obs_txt" value="<?php echo $_POST['obs_txt'];?>" />
</label>
</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><span class="Estilo18">Desea registrar los datos mostrados? </span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><label>
<div align="center">
<input type=button value=No onclick=document.location='principal_admin.php' />
<span class="Estilo22">.........</span>
<input type="submit" name="si_btn" id="si_btn" value="Si" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form_confirmar_registro" />
</form>
</td>
</tr>
</table>
</body>
</html>