?
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
Medium Priority
?
198 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 51

Accepted Solution

by:
Steve Bink earned 1200 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 800 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 51

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

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 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