Foros del Web » Programando para Internet » PHP »

Fatal error: Maximum execution time

Estas en el tema de Fatal error: Maximum execution time en el foro de PHP en Foros del Web. Buenas Estoy haciendo un tag-board formado por 3 archivos: - tag.php : Contiene un frame que muestra el archivo mensajes.php, el formulario para enviar el ...
  #1 (permalink)  
Antiguo 11/12/2008, 17:16
 
Fecha de Ingreso: julio-2008
Ubicación: El Puerto de Santa María
Mensajes: 62
Antigüedad: 15 años, 9 meses
Puntos: 0
Fatal error: Maximum execution time

Buenas

Estoy haciendo un tag-board formado por 3 archivos:
- tag.php: Contiene un frame que muestra el archivo mensajes.php, el formulario para enviar el mensaje, cuyo action es el mismo tag.php
- mensajes.php: Busca los mensajes y los muestra
- mensajes.txt: Donde se almacenan los mensajes.

El error es el siguiente:

Fatal error: Maximum execution time of 60 seconds exceeded in C:\Documents and Settings\Ale\Escritorio\xampplite\htdocs\tag.php on line 32

Y el tag.php lo siguiente:
Código php:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Documento sin título</title>
  6. <style type="text/css">
  7. <!--
  8. body {
  9.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  10.     font-size: 8pt;
  11. }
  12. -->
  13. </style></head>
  14.  
  15. <body>
  16. <?php
  17. $nick = $_POST['nick'];
  18. $url = $_POST['url'];
  19. $mensaje = $_POST['mensaje'];
  20. if (!empty ($mensaje)) {
  21.     $palabras = explode (" ",  $mensaje);
  22.     foreach ($palabras as $indice => $valor) {
  23.         $longitud = strlen ($valor);
  24.         if ($longitud > 22) {
  25.             echo ("Tu mensaje contiene palabras demasiado largas");
  26.         } else {
  27.             $mensaje = '<a href="' . $url . '" target="_blank">' . $nick . '</a>:<br />' . $mensaje . '\n';
  28.             $archivo = "mensajes.txt";
  29.             $abrir = fopen ($archivo, "r+");
  30.             $leer = fread ($abrir, filesize ($archivo));
  31.             $numero_linea = 1;
  32.             while (!feof ($abrir)) {
  33.                 $numero_linea++;
  34.             }
  35.             if ($numero_linea > 20) {
  36.                 fclose ($abrir);
  37.                 $abrir = fopen ($archivo, "w");
  38.                 fwrite ($abrir, $mensaje);
  39.                 fclose ($abrir);
  40.             } else {
  41.                 if ($leer == 0) {
  42.                     fwrite ($abrir, $mensaje);
  43.                     fclose ($abrir);
  44.                 }
  45.             }  
  46.         }
  47.     }
  48. }
  49. ?>
  50. <table border="0" width="190" height="365" cellpadding="0" cellspacing="0" style="border: 1px #000000 solid; margin: 5px auto;">
  51. <tr>
  52. <td height="250">
  53. <iframe src="mensajes.php" width="190" height="250" marginheight="0" marginwidth="0" noresize scrolling="yes" frameborder="0">
  54. </iframe>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td valign="top" style="padding: 5px; border-top: 1px #000000 solid;"><form id="form1" name="form1" method="post" action="tag.php">
  59.   <table width="180" border="0" cellspacing="0" cellpadding="2">
  60.     <tr>
  61.       <td width="62" valign="middle" style="text-align: right">Nick:</td>
  62.       <td width="110" valign="middle" style="text-align: left"><label>
  63.         <input name="nick" type="text" id="nick" size="15" maxlength="12" />
  64.       </label></td>
  65.     </tr>
  66.     <tr>
  67.       <td valign="middle" style="text-align: right">URL:</td>
  68.       <td valign="middle" style="text-align: left"><label>
  69.         <input name="url" type="text" id="url" size="15" maxlength="50" />
  70.       </label></td>
  71.     </tr>
  72.     <tr>
  73.       <td valign="middle" style="text-align: right">Mensaje:</td>
  74.       <td valign="middle" style="text-align: left"><label>
  75.         <input name="mensaje" type="text" id="mensaje" size="15" maxlength="255" />
  76.       </label></td>
  77.     </tr>
  78.     <tr>
  79.       <td valign="middle" colspan="2" style="text-align: center"><label>
  80.         <input type="submit" name="enviar" id="enviar" value="Enviar" />
  81.       </label></td>
  82.       </tr>
  83.   </table>
  84. </form></td>
  85. </tr>
  86. </table>
  87. </body>
  88. </html>

Gracias
  #2 (permalink)  
Antiguo 11/12/2008, 17:42
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Fatal error: Maximum execution time

Código:
while (!feof ($abrir)) {
        $numero_linea++;
}
La condición nunca se da porque no lees la siguiente linea. Mejor lee el archivo completo de una vez con

Código:
$lineas = explode("\n", file_get_contents($archivo));
$numero_linea = count($lineas);
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 11/12/2008, 17:48
 
Fecha de Ingreso: julio-2008
Ubicación: El Puerto de Santa María
Mensajes: 62
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Fatal error: Maximum execution time

Muchas gracias!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:57.