If you are stuck using a database, such as MySQL, that does not support transactions, you may find that on a particular script you need to do several insert/update queries that either all, or none, must be run.
One good idea is to put this at the very top of your script:
// Prevent user from aborting script $old_abort = ignore_user_abort(true);
And then this at the bottom:
// Reset abort setting ignore_user_abort($old_abort);
This will stop the user pressing 'Stop' from ruining your script!