note 18662 added to function.connection-status
| From: | carlos at fischerinformatica dot com dot br | Date: | Wed, 30 Jan 2002 23:58:23 +0000 |
| Subject: | note 18662 added to function.connection-status | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26052@lists.php.net to get a copy of this message | ||
Very very useful!
I was building a chat and I wanted my script to detect when the browser was closed, so the user
could be deleted from the online_users table.
<?
echo str_repeat(" ",300);
ignore_user_abort(true); //this way, the user can stop the output, but not the script.
while (true) {
echo "test<br>\n";
flush();
sleep(2);
if (connection_status()!=0){
include ('dbconnect.inc');
$sql="delete from online_users where online_user=$user";
$sql_exec=pg_exec($vChatDB, $sql);
die(); //kills the script
}
}
?>
--
http://www.php.net/manual/en/function.connection-status.php
http://master.php.net/manage/user-notes.php?action=edit+18662
http://master.php.net/manage/user-notes.php?action=delete+18662
http://master.php.net/manage/user-notes.php?action=reject+18662