Solved

i am using wamp and if i run a script that insert data into mysql and lets say i want to stop the script i click at the stop button in the browzer but the script contnues working

Posted on 2008-10-09
3
189 Views
Last Modified: 2012-06-21
i am using wamp and if i run a script that insert data into mysql and lets say i want to stop the script i click at the stop button in the browzer but the script contnues working

why?
and how i fix this
0
Comment
Question by:mgtm3
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 300 total points
ID: 22683941
Once the script begins running, there's not a lot of option for you.  The server will not know that the client has terminated the load, since the client is not involved until *after* the script terminates.  The script will always continue running until it ends, either normally or through a fatal error.
0
 
LVL 25

Assisted Solution

by:Squinky
Squinky earned 200 total points
ID: 22685697
That's not quite true. PHP scripts will normally terminate on user cancellation unless you call ignore_user_abort(): http://www.php.net/manual/en/function.ignore-user-abort.php

What generally will carry on even if the PHP script stops is any pending mysql queries. This only applies to the one that is running at the time of cancellation - it won't do any more after that.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 22686049
I think that will be for "stateful" protocols, not HTTP.  Also, from the "Notes" section for that function:

"PHP will not detect that the user has aborted the connection until an attempt is made to send information to the client."

If the client returns nothing (as an HTTP client would if the user has aborted the page load), PHP may not realize that the connection was actually aborted.  In other words, the script continues, and PHP tries to push everything, but it is ignored on the client side.

Check the headers of an HTTP page load, and you'll see what I mean.  The client will send a header for each request, but will send nothing for an early termination (such as pressing 'ESC' or clicking "Stop").

Of course a simple experiment will prove this out.  Create a really long HTML page with a query at the end of it.  Break the page load, then check to see if the query executed.  IME, it always has.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now