In a small application, I’m writing, during installation phase, the user must enter detail about the MySQL connection in a form (server name, database name, username …)
I would like to display line by line the result of tests and actions done in a window, with eventually a small pause between each test, like :
“Connection to the server …”(2s) “ok” (2s)
“Connection to the database …”(2s) “ok” (2s)
“Creation of tables …”(2s) “ok”
….etc
I have tried with ob_start(), flush(), ob_flush() but it doesn’t work as my webserver seems to buffer itself the php output, so the script takes a long time to run but everything is printed at the same time.
I have searched here and with Google, without any result (may be not with the correct keywords)
Can you point me to solution ?
with Ajax may be ?
ericc
There are multiple solutions to this, but disabling caching altogether isn’t easily accomplished.
Because on the server side there is some caching, which can be disabled, but there is also a very large chance that the browser is caching as well.
To fix this you have a few options:
fake it, display a static javascript based “animation” and redirect when done.
Use ajax, let the installation script
echothe results to a text file / mysql database and use a different php script to load the the text file / database at set intervals and display the new results.Use the newest HTML5/javascript streaming API which is made exactly for stuff like this, it is, however, quite hard to find any good documentation on this.
To disable server side caching, I use this code: