Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/02/2008, 08:06
gesking
 
Fecha de Ingreso: diciembre-2006
Mensajes: 294
Antigüedad: 17 años, 4 meses
Puntos: 2
Eliminar ultimo registro

Hola, tengo un problema. Tengo un boton llamado "agregar" que al hacer clic inserta nuevos datos a la base de datos. Pero tengo otro boton "eliminar" en donde quiero que al clic se borre el ultimo registro.

Yo pensé... Bueno, selecciono el ultimo registro y lo muestro en DELETE, pero me sale este error:

Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

Este es mi script:
Código PHP:
session_start();
if (isset(
$_SESSION['admin'])) {
include(
"../config.php");

$resp mysql_query("SELECT * FROM radio_progra ORDER BY id DESC LIMIT 1");
$row mysql_fetch_array($resp);

$sql mysql_query("delete from hostimage_imagenes where id='$row[id]'") or die("Error: ".mysql_error());
$res mysql_query($sql) or die("Error: ".mysql_error());
header("Location: index.php");

}else{
echo 
'Tu no estas autentificado. No puedes entrar aqui!!<br><br><a href="index.php">Volver</a>';

Desde ya gracias