Ver Mensaje Individual
  #15 (permalink)  
Antiguo 22/03/2014, 21:07
cdisenia
 
Fecha de Ingreso: junio-2012
Mensajes: 30
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: No puedo editar una base de datos

Hola a todos y muchas gracias a todos. He probado el código de gnzsoloyo funcionó solo le hice una modificación en el where id=".$_POST["id"]; por where id=$id"; entonces el código quedo así:

Código PHP:
Ver original
  1. //print_r($_POST);
  2. require_once("../conexion/conexion.php");
  3. $sql="update noticia
  4. set categoria_id='".$_POST["categoria_id"]."',
  5. subcategoria_id='".$_POST["subcategoria_id"]."',
  6. titulo='".$_POST["titulo"]."',
  7. subtitulo='".$_POST["subtitulo"]."',
  8. detalle='".$_POST["detalle"]."',
  9. foto= '".$_POST["foto"]."',
  10. fuente= '".$_POST["fuente"]."'
  11. where id=$id";
  12.  
  13. echo $sql;
  14.  
  15. $res=mysql_query($sql,$con) or die("Error: ".mysql_error());
  16.  
  17. if($res)
  18.     {echo "<script type=''>
  19.    alert('Los datos de la noticia fueron modificados correctamente');
  20.    window.location='administrador-noticias.php';
  21.    </script>";  
  22. }

Ahora bien, se modifica todo menos la foto no se carga, es como si borraría la que estaba cuando la quiero cambiar por otra, no se si tiene algo que ver por las fotos en base de datos son del "tipo blob", le hago mostrar la base de datos:

Código MySQL:
Ver original
  1. TABLE `noticia` (
  2.   `titulo` varchar(255) NOT NULL default '',
  3.   `subtitulo` text NOT NULL,
  4.   `detalle` text NOT NULL,
  5.   `fuente` varchar(255) NOT NULL default '',
  6.   `categoria_id` int(1) NOT NULL,
  7.   `subcategoria_id` int(1) NOT NULL,
  8.   `foto` blob NOT NULL,
  9.   `thumb` blob NOT NULL,
  10.   `mime` varchar(40) NOT NULL default '',
  11.   PRIMARY KEY  (`id`)
  12. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ;

He probado dejando que se modifique todo menos la foto y se modifica bien y no se borra la foto, se muestra la foto con que se subió la noticia, no se cual sea el problema, como dije anteriormente gracias a todos por ayudarme.