When running a long query from PHP, [how] can I kill the query if the user presses stop in their browser?
Take into consideration that I cannot call
i think you can give a try to mysql KILL
http://dev.mysql.com/doc/refman/5.0/en/kill.html
if you are able to call something over user abort then you can use KILL to kill you mysql connection or query by fetching it's process id.
And as you said in your comment that PHP is blocked until mysql returns
so you can take help from javascript in this way:
1.detect the user abort using JS 2.call a function on user abort 3.in that function you can kill you previous query but here you need the process id of the previous query so you can get that by a trick that you can select the process id when you run you first long query and pass it to JS function and use it in killing you query.
Hope it will help you.