Ver Mensaje Individual
  #22 (permalink)  
Antiguo 17/01/2013, 09:54
Avatar de Most
Most
 
Fecha de Ingreso: marzo-2009
Mensajes: 642
Antigüedad: 15 años, 1 mes
Puntos: 6
Respuesta: limite en archivo de texto

Cita:
Iniciado por dashtrash Ver Mensaje
Mismo problema..Tienes que poner $currentFile como primer parametro en *todas* las llamadas a fwrite..
Ok, ahora si me escribe, pero solo una vez, despues de esa vez, lo que hace es reemplazarme el antiguo texto por el nuevo

Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <title>Problema</title>
  4. </head>
  5. <body>
  6. <?php
  7. //Obtenemos ID
  8. $id=$_GET[id];
  9. //Seleccionamos BD
  10. require("conexion.php");
  11. $res=mysql_query("select * from navi where id_navi='$id'",$connect);
  12.  
  13. $counter=0;
  14. $text="";
  15. $currentFile=null;
  16.  
  17. $cabecera="
  18. version=7
  19. background=http://ps3tv.square7.ch/fondotaquillas/cine.jpg
  20. title=Nacionales
  21. logo=http://www.todoiphone.net/wp-content/uploads/2012/02/retro-tv-icon.jpg
  22. \n";
  23. $pie="Este es mi pie";
  24.  
  25. // $res es el resultado de mysql_query de tu consulta.
  26. while($row=mysql_fetch_array($res))
  27. {
  28.      if($counter%40==0)
  29.      {
  30.             if($currentFile!=null)
  31.             {
  32.                 fwrite($currentFile, $pie);          
  33.                 fclose($currentFile);
  34.              }
  35.              $currentFile=fopen("miFichero".($counter/40).".txt","w");
  36.              fwrite($currentFile, $cabecera);
  37.      }
  38.     fwrite($currentFile, "# ".$row[id_navi]."
  39. type=video
  40. name=".$row[titulo]."
  41. thumb=".$row[caratula]."
  42. URL=".$row[url]."
  43.            ".$row[procesador]."\n\n");
  44.     $counter++;
  45. }
  46. if($currentFile)
  47.      fclose($currentFile);
  48.      
  49. header("location: publicaciones.php");
  50.  
  51.   ?>
  52.  
  53. </body>
  54. </html>

Última edición por Most; 17/01/2013 a las 16:03