Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2010, 15:11
pcisterna
 
Fecha de Ingreso: julio-2010
Mensajes: 5
Antigüedad: 14 años, 4 meses
Puntos: 0
Problema con inserción a MySQL

Estimados:

Estoy tratando de realizar una inserción a una tabla, anteriormente ya habia realizado este tipo de insercion, pero esta vez no logro que entre a la BD.

Les dejo el codigo, para ver si ustedes pueden hacer algo.


<?php require_once('../Connections/Worldcolor.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "registro_nulo.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?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']);
}
mysql_select_db($database_Worldcolor, $Worldcolor);
if(isset($_POST['Submit'])){
$strquery="insert into partes_oprealizadas (IDParte, IDOpPrinergy, Seccion, Proceso, operacion, HrTermino, Bueno, Malo, Comentario, CTFPaginas) values";
for($i=0;$i<count($_POST['IDParte']);$i++){
$strquery.="( '".$_POST['IDParte'][$i]."','".$_POST['IDOpPrinergy'][$i]."','".$_POST['Seccion'][$i]."','".$_POST['Proceso'][$i]."','".$_POST['operacion'][$i]."','".$_POST['HrTermino'][$i]."','".$_POST['Bueno'][$i]."','".$_POST['Malo'][$i]."','".$_POST['Comentario'][$i]."','".$_POST['CTF'][$i]."') ,";
}
$strquery=substr($strquery,0,(strlen($strquery)-1)).';';
mysql_query("$strquery");

Formulario


<p><form action="" method="post" name="form1" id="form1">
<p>&nbsp;</p>
<table border="1" align="center">
<tr>
<td>&nbsp;</td>
<td>Inicio</td>
<td>Fin</td>
<td>OT</td>
<td>Nombre</td>
<td>Pliego</td>
<td>Lado</td>
<td>Operacion</td>
<td>Bueno</td>
<td>Malo</td>
<td>Comentario</td>
</tr>
<?php do { ?>
<tr>
<td><input name="IDOpPrinergy[]" type="checkbox" id="IDOpPrinergy[]" value="<?php echo $row_SalidaImproof['ID']; ?>" />
<label for="IDOpPrinergy[]"></label></td>
<td><?php echo $row_SalidaImproof['Hora']; ?></td>
<td><input name="HrTermino[]" type="text" id="HrTermino[]" value="<?php echo $row_SalidaImproof['Hora']; ?>" size="12" /></td>
<td><?php echo $row_SalidaImproof['OT']; ?></td>
<td><?php echo $row_SalidaImproof['OTNombre']; ?></td>
<td><input name="CTF[]" type="text" id="CTF[]" value="<?php $nombrepliego = preg_replace('([A-Za-z\_])s', "", $row_SalidaImproof['Pliego']); echo substr($nombrepliego , 5);?>" size="12" readonly="readonly" /></td>
<td><?php echo $row_SalidaImproof['Lado']; ?></td>
<td><select name="operacion[]" id="operacion[]">
<?php
do {
?>
<option value="<?php echo $row_OperacionesImproof['ID']?>"<?php if (!(strcmp($row_OperacionesImproof['ID'], 300))) {echo "selected=\"selected\"";} ?>><?php echo $row_OperacionesImproof['Operacion']?></option>
<?php
} while ($row_OperacionesImproof = mysql_fetch_assoc($OperacionesImproof));
$rows = mysql_num_rows($OperacionesImproof);
if($rows > 0) {
mysql_data_seek($OperacionesImproof, 0);
$row_OperacionesImproof = mysql_fetch_assoc($OperacionesImproof);
}
?>
</select></td>
<td><input name="Bueno[]" type="text" id="Bueno[]" value="<?php echo $row_SalidaImproof['Cantidad']; ?>" size="12" /></td>
<td><input name="Malo[]" type="text" id="Malo[]" value="" size="12" /></td>
<td><input name="Comentario[]" type="text" id="Comentario[]" value="<?php echo $row_SalidaImproof['Comentario']; ?>" size="12" /></td>
</tr>
<?php } while ($row_SalidaImproof = mysql_fetch_assoc($SalidaImproof)); ?>
</table>
<table width="50%" align="center">
<tr valign="baseline">
<td align="center" valign="middle" nowrap="nowrap"><input name="GrabarImproof" type="submit" id="GrabarImproof" value="GrabarImproof" /></td>
</tr>
</table>
<p>&nbsp;</p>
<p>
<input name="IDParte[]" type="hidden" id="IDParte[]" value="<?php echo $_GET['IDParte']; ?>" />
<input name="Seccion[]" type="hidden" id="Seccion[]" value="<?php echo $row_ParteRegistrado['seccionID']; ?>" />
<input name="Proceso[]" type="hidden" id="Proceso[]" value="30" />
</p>
</form>