Ver Mensaje Individual
  #6 (permalink)  
Antiguo 24/08/2012, 15:42
angelb182
 
Fecha de Ingreso: agosto-2012
Mensajes: 4
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Error en mi codigo de noticias

Gracias por tu respuesta y por tu ayuda.
Suprimi $connect

Ahora nadamas me da este error.
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Pagina_OpaMexicana\SistemaNoticias \moderacion\editar.php on line 17

Asi quedo el codigo..Estoy bien..?

Código PHP:
Ver original
  1. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="es-ES">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <meta name="robots" content="noindex,nofollow" />
  5. <title>Editar noticia</title>
  6. </head>
  7. <body>
  8. <?php
  9. // Declaramos la variable ID en la que recibimos el ID que pusimos en la URL, por tanto, recibimos el ID de la noticia que queremos borrar
  10. $id = ''; if (isset($_POST['id'])) { $id = $_POST['id']; }  
  11. // Conectamos a la base de datos
  12. mysql_connect("localhost","root","");
  13. // Seleccionamos la base de datos
  14. mysql_select_db("prueba");
  15. // Seleccionamos la noticia correspondiente dependiendo del ID especificado en la URL
  16. $result=mysql_query("SELECT * FROM 'prueba'.'novedades' WHERE id_noticia=$id");
  17. if (mysql_num_rows($result)) {
  18.    while ($qry = mysql_fetch_array($result)) {
  19. // Mostramos un formulario con los datos de la noticia puestos en inputs para poder modificarlos
  20. echo "<form method='post' action='actualizar.php'>
  21. <input type='hidden' name='id' id='id' value='$id' />
  22. Título de la noticia: <input type='text' name='titulo' id='titulo' value='$qry[titulo]' /><br />
  23. Autor de la noticia: <input type='text' name='autor' id='autor' value='$qry[autor]' /><br />
  24. Categoría de la noticia: <input type='text' name='categoria' id='categoria' value='$qry[categoria]' /><br />
  25. Fecha de la noticia (Tienes que ponerla en formato AÑO-MES-DÍA): <input type='text' name='fecha' id='fecha' value='$qry[fecha]' /><br />
  26. Contenido de la noticia: <textarea name='novedad' id='novedad'>$qry[novedad]</textarea><br />
  27. <button type='submit'>Editar noticia</button>
  28. </form>";
  29. }
  30. }
  31. ?>
  32. </body>
  33. </html>