Ver Mensaje Individual
  #9 (permalink)  
Antiguo 14/02/2010, 10:12
patricia:)
 
Fecha de Ingreso: abril-2006
Ubicación: Venezuela
Mensajes: 126
Antigüedad: 18 años
Puntos: 0
Respuesta: form de busqueda, modificacion y eliminacion

Buenas nuevamente, les comento ajuste la config del php.ini como indicado en un post "configuracion correcta del PHP.ini", reinicie los servicios web. probe la pagina y el error me persiste al omento de eliminar no borra ningun registro.

Entonces probe con este codigo:

En el boton eliminar:
Código:
<input type="submit" name="cmdeli" id="cmdeli" value="Eliminar" onclick="eliminar(t1)"/>
Pregunta de validacion para eliminar el registro:
Código:
<script language="javascript">
function eliminar(codigo)
{
respuesta=confirm("Deseas Eliminar este registro");
if (respuesta==true)
{
window.location="deletealumno.php?codigo="+codigo;
}
}
</script>
y la pagia de eliminacion del registro:
Código:
<?php require_once('Connections/cn.php'); ?>
<?
echo $_GET['codigo'];
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['codigo'])) && ($_GET['codigo'] != "")) {
  $deleteSQL = sprintf("DELETE FROM alumnos WHERE codigo=%s",
                       GetSQLValueString($_GET['codigo'], "int"));
  mysql_select_db($database_cn, $cn);
  $Result1 = mysql_query($deleteSQL, $cn) or die(mysql_error());
  if(mysql_affected_rows()!=0)
  {
   echo '<script>alert("Registro eliminado.");</script>';
   
  } 
}
?>

y el archivo de conexion "cn.php":
Código:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_cn = "localhost";
$database_cn = "controlestudio";
$username_cn = "root";
$password_cn = "123";
$cn = mysql_pconnect($hostname_cn, $username_cn, $password_cn) or trigger_error(mysql_error(),E_USER_ERROR); 
?>


Pues al probar la pagina y al hacer clic en eliminar me pregunta: Desea eliminar el registro?. Hasta aqui todo bien. El error me da que al hacer clic en OK no borra nada. :-/