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
193 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:Marcus Bointon
Marcus Bointon 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

809 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