I am testing a PHP script on my server and I noticed that when I visit the script page in my browser and click "stop" before the script has finished executing then the browser closes the connection with the server and outputs its own "page not found" error page, but even after the browser has closed the connection the script keep running on my server until it is completely executed. For a quick test, I have made a test script that sleeps for 10 seconds and then stores some data in a database, now I visited that script in my browser and quickly clicked "stop" so that the browser gave me a "page not found" error but nevertheless the script kept running on my server 'til its end and the data was stored in the database indicating that the statements after the 10 sec sleep has been executed! Is there anyway I can make my scripts exit immediately when someone clicks "stop" (ie the user browser cuts the connection) even before it's finished executing?
I'd listen to nico instead of me... I'm an ASP guy trying to make the transition to PHP, while nico has proven his PHP-ability time and time again...
Two PHP functions that may assist you in this: exit(); Code (markup): and mysql_close(); Code (markup):