Necesito actualizar registros
Estimados... tengo una pagina que actualiza registro... me abre la informaci贸n de la base de datos en el formulario sin problemas, cambio lo que sea, pero al darle al boton me agrega el cambio como registro nuevo. 驴D贸de est谩 el error?... Publico el c贸digo a ver si un alma caritativa me echa una mano. MUCHAS GRACIAS ;)
-----------
<?php require_once('../Connections/juancarlos.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 revista_book (fichero, descripcion, fecha) VALUES (%s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['fichero'], "text"),
GetSQLValueString($HTTP_POST_VARS['descripcion'], "text"),
GetSQLValueString($HTTP_POST_VARS['fecha'], "text"));
mysql_select_db($database_juancarlos, $juancarlos);
$Result1 = mysql_query($insertSQL, $juancarlos) or die(mysql_error());
$insertGoTo = "archivo_in.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_juancarlos, $juancarlos);
$query_Recordset1 = "SELECT * FROM revista_book ORDER BY fecha ASC";
$Recordset1 = mysql_query($query_Recordset1, $juancarlos) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
-----------
<?php require_once('../Connections/juancarlos.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 revista_book (fichero, descripcion, fecha) VALUES (%s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['fichero'], "text"),
GetSQLValueString($HTTP_POST_VARS['descripcion'], "text"),
GetSQLValueString($HTTP_POST_VARS['fecha'], "text"));
mysql_select_db($database_juancarlos, $juancarlos);
$Result1 = mysql_query($insertSQL, $juancarlos) or die(mysql_error());
$insertGoTo = "archivo_in.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_juancarlos, $juancarlos);
$query_Recordset1 = "SELECT * FROM revista_book ORDER BY fecha ASC";
$Recordset1 = mysql_query($query_Recordset1, $juancarlos) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
