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
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 …

730 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