...

View Full Version : Bufferering or background task ? .. help !



tk5ep
01-02-2006, 03:49 PM
Hi all,

I have a script that calls another one which has a loop that reads a huge file (mine actualy 14 Mb) and reads it line by line (actualy 55000), parses them and makes an INSERT in a MySQL database.
The file can even be larger ...

At start of script i display a short info and normaly each time an error is detected in a line, it should diplay a warning.
At the end of script, i display the result : number of line inserted and number of errors.

If everything works ok on small files (about several thousand of lines) i do have a problem on large files. The execution time (70-80 s) is beyond time out of server and browser. It also depends on what server it runs.
In some configuration, nothing is displayed until end of script, with others the begining is displayed than nothing, sometimes it timeouts and nothing is done.

How can i make the script run in background and/or display a progress bar or something that would warn the client that something happens ?

I tried to send a == to the browser at x loops but that does not solve my problem. I tried to optimize evrything i could in parsing and MySQL command... (can't use LOAD DATA INFILE due to server restrictions)

Every help is welcome.
A happy new year to all readers.

Mithrilhall
01-02-2006, 05:27 PM
Do you have access to the php.ini file? If so you could change the timeout setting.

Also, why not diplay an image to the user while your page is doing it's thing?
http://mentalized.net/activity-indicators/

This might help as well....http://us3.php.net/flush


Check out some ajax examples as I think they would work for you here.
http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-Tutorial.html

tk5ep
01-02-2006, 05:43 PM
Thanks for answer.

I forgot to tell that i could not manage to make flush() work in my script, even if it should !! No way...:confused:

I will have a look on AJAX page you gave me. It seems that AJAX is the future... I use it intensively every day ! But as a customer in GMAIL. :)

Thanks for the nice pictures, i can use them but the problem is that my script is timing out if i do nothing !

Patrick,


Do you have access to the php.ini file? If so you could change the timeout setting.

Also, why not diplay an image to the user while your page is doing it's thing?
http://mentalized.net/activity-indicators/

This might help as well....http://us3.php.net/flush


Check out some ajax examples as I think they would work for you here.
http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-Tutorial.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum