Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
199 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

598 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