Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/12/2008, 19:57
dti3000
 
Fecha de Ingreso: diciembre-2008
Mensajes: 30
Antigüedad: 15 años, 4 meses
Puntos: 0
problema para borrar registro de BBDD

Hola amigos, tengo un problema, he seguido un manual de cómo borrar un registro de una base de datos. Tengo dos paginas: registros2.php y borrar.php, en registros2.php he puesto unos botones para realizar el borrado de cada registro, estos envian correctamente la id del objeto a borrar a la pagina borrar.php, pero cuando le pulso al botón borrar del pequeño form no funciona. Agradecería alguna sugerencia a mi código:

<?php require_once('../../Connections/tramp.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;
}

if ((isset($_GET['campo_id'])) && ($_GET['campo_id'] != "")) {
$deleteSQL = sprintf("DELETE FROM p2_lp WHERE id=%s",
GetSQLValueString($_GET['campo_id'], "int"));

mysql_select_db($database_tramp, $tramp);
$Result1 = mysql_query($deleteSQL, $tramp) or die(mysql_error());

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

$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_tramp, $tramp);
$query_Recordset1 = sprintf("SELECT * FROM p2_lp WHERE id = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $tramp) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<p><?php echo $row_Recordset1['No_Doc']; ?> <?php echo $row_Recordset1['Título']; ?></p>
<form id="form1" name="form1" method="post" action="">
<input name="campo_id" type="hidden" id="campo_id" value="<?php echo $row_Recordset1['id']; ?>" />
<input type="submit" name="Submit" value="borrar" />
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>