I've got a script that processes an arbitrary number of jpg files in a directory, writes thumbnail versions to a 'thumbs' directory, adds data about the images to the database, and then, at the end, spits out all the little comments it was making as it did the processing. I'm having two problems:

  1. If I process more than, say, 12 images at once, the WHILE loop seems to just quit halfway through and the script stops running. It successfully processes and databases the first 12, but any other files in the directory are left unprocessed. ??

  2. Is there a way to show incremental comments during the process, instead of having to wait for the whole thing to end before giving the user any feedback... at the very least, having it say something like "Processing..." would be nice. Right now, you hit SUBMIT on the previous page, and then you get a blank screen until the whole thing is done...very unnerving.

    1. Check your PHP.INI file (inside \WINDOWS or \WINNT), make sure the script time limit is set high enough. Default is 30 seconds. Look for the line
      "max_execution_time = 30;". Change it to something higher. If that does not fix it, let me know (possibly send your loop code?)
    2. Yes. In each iteration, do:
      print "Processing... image # $imagenum<br>";
      flush();

    The flush is important, since it will force the ouput. This does not guarantee that the line will be displayed immediately though: Apache seems to have its own output buffering, and I have written similar loop scripts that dont get any output show in the browser until about the 10th iteration (YMMV).

      Put set_time_limit(0) for unlimited executing time or use a larger number than the default of 30 seconds.

      If you print \n characters at the end of the lines and you call flush() after printing, it should display in Netscape or IE.

        Just take note of
        http://www.php.net/manual/en/function.flush.php

        "Note: flush() has no effect on the buffering scheme of your webserver or the browser on the client side.

        Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser."

        I run on 2000 with Apache 1.3.20, and this definately is true. It does not flush immediately.

          Write a Reply...