List:General Discussion« Previous MessageNext Message »
From:Nigel Wood Date:April 16 2010 11:31am
Subject:Re: What if the user closes the browser while INSERT INTO MySQL?
(PHP/MySQL)
View as plain text  
> > Consider the following concept,
> >
> > ~/index.php
> >
> > #1. Fetch data from an external webpage using PHP Curl;
> > #2. Preg_match/Prepare Data to INSERT from local MySQL; - this may take a
> > few secs
> > #3. While Loop { INSERT data (from #2) into local MySQL } - this may take
> > only mili secs.
> >
> > Suppose this code is run by a random user (say, my website visitor), and
> > he/she closes the browser while the code was running. The real problem is
> > when the browser is closed while #3 is executing. 
<snip>
> The server does not know if the browser is closed or not (or if the network 
> connection is losted). It will continue to execute the code until finnished.

I'm not sure that's exactly correct. "The default behaviour is however
for your script to be aborted when the remote client disconnects."
http://www.php.net/manual/en/features.connection-handling.php 

You can certainly set a script not to terminate if the user aborts
during the page request using ignore_user_abort() or a php.ini setting.

HTH 

Nigel

P.S. Sorry to the other list users for a PHP oriented discussion.


Thread
What if the user closes the browser while INSERT INTO MySQL? (PHP/MySQL)Antonio PHP16 Apr
  • Re: What if the user closes the browser while INSERT INTO MySQL? (PHP/MySQL)Jørn Dahl-Stamnes16 Apr
    • Re: What if the user closes the browser while INSERT INTO MySQL? (PHP/MySQL)Geert-Jan Brits16 Apr
    • Re: What if the user closes the browser while INSERT INTOMySQL? (PHP/MySQL)Carsten Pedersen16 Apr
      • Re: What if the user closes the browser while INSERT INTO MySQL? (PHP/MySQL)Antonio PHP17 Apr
    • Re: What if the user closes the browser while INSERT INTO MySQL?(PHP/MySQL)Nigel Wood19 Apr
      • Re: What if the user closes the browser while INSERT INTO MySQL? (PHP/MySQL)Johan De Meersman19 Apr
        • Re: What if the user closes the browser while INSERT INTO MySQL? (PHP/MySQL)Michael Dykman19 Apr
  • Re: What if the user closes the browser while INSERT INTOMySQL? (PHP/MySQL)Carsten Pedersen16 Apr