Ver Mensaje Individual
  #12 (permalink)  
Antiguo 23/08/2010, 12:48
Gabprog
 
Fecha de Ingreso: mayo-2009
Ubicación: Leganés - Madrid
Mensajes: 37
Antigüedad: 15 años
Puntos: 1
Respuesta: Depuración de Código - No borra registro en BD

Cita:
Iniciado por DooBie Ver Mensaje
Una buena idea sería el postear de nuevo el codigo de editar.php, borrar.php y el resultado que te sale en el navegador en ambos casos.
Aqui esta:

editar.php
Código PHP:
<html>
<head>
</head>
<body>
<?php

//recibimos la variable id enviada en el enlace por GET
$id_noticia=$_GET[id_noticia];

//conectamos a la base
$connect=mysql_connect("xxxx","xxx","xx");
//Seleccionamos la base
mysql_select_db("xx",$connect);


//hacemos las consultas
$result=mysql_query("select * from noticias order by id_noticia Desc"$connect);

//Una vez seleccionados los registros los mostramos para su edición
while($row=mysql_fetch_array($result))
{
echo 
' <form method="post" action="edit.php">
<input type="hidden" name="id_noticia" value="'
.$row[id_noticia].'"><br>
T&iacute;tulo not&iacute;cia:<br>
<input type="text" name="titulo" value="'
.$row[titulo].'"><br>
Autor:<br>
<input type="text" name="autor" value="'
.$row[autor].'"><br>
Categor&iacute;a:<br>
<input type="text" name="categoria" value="'
.$row[categoria].'">

<br>Escriba el art&iacute;culo<br>
<textarea name="noticia" cols="50" rows="10">"'
.$row[noticia].'" </textarea>
<br>
<input type="submit" value="Editar"><br>
</form>'
;
?>
<a href="borrar.php?id=<?php echo $row['id_noticia']; ?>">Borrar</a>
<?php
}
mysql_free_result($result);
mysql_close($connect);
?>
</body>
</html>

borrar.php
Código PHP:
<?
//recibimos la variable $id
$id_noticia=$_GET[id_noticia];

//conectamos a la base
$connect=mysql_connect("xx","xx","xx");
//Seleccionamos la base
mysql_select_db("xx",$connect);

//borramos los registros pertenecientes a la id
mysql_query("delete from noticias where id_noticia='$id_noticia'"$connect);

header("location: index.php");
?>
Resultado en el navegador de:

1) editar.php
[URL="http://bit.ly/ahT5M4"]http://bit.ly/ahT5M4[/URL]

2) borrar.php
[URL="http://bit.ly/b2ql7x"]http://bit.ly/b2ql7x[/URL]

Saludos!