X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 483B2D1CA82 for ; Wed, 19 Nov 2003 17:36:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25917-03 for ; Wed, 19 Nov 2003 13:35:45 -0400 (AST) Received: from smtp-1.indo.net.id (smtp-1.indo.net.id [202.159.32.91]) by svr1.postgresql.org (Postfix) with SMTP id 96BB0D1CCDF for ; Wed, 19 Nov 2003 13:34:53 -0400 (AST) Received: (qmail 11967 invoked from network); 20 Nov 2003 00:34:48 +0700 Received: from smtp.indo.net.id (202.159.32.81) by smtp-1.indo.net.id with SMTP; 20 Nov 2003 00:34:48 +0700 Received: (qmail 19343 invoked from network); 19 Nov 2003 17:32:02 -0000 Received: from unknown (HELO smtp.surabaya.indo.net.id) (202.159.51.117) by smtp.indo.net.id with SMTP; 19 Nov 2003 17:32:02 -0000 Received: from smtp [202.159.51.117] by smtp.surabaya.indo.net.id (SMTPD32-7.10) id AC6B3251003E; Thu, 20 Nov 2003 00:46:19 +0700 Received: FROM middinkcomp BY smtp ; Thu Nov 20 00:46:16 2003 +0700 Message-ID: <00aa01c3aec5$3fb5df60$2b179fca@middinkcomp> From: "Muhyiddin A.M Hayat" To: "Noel" , References: <3FB984FA.1090003@med.monash.edu.au> Subject: Re: Cancel a query when user leaves a web page Date: Thu, 20 Nov 2003 01:44:08 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_009D_01C3AF07.CA3727B0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=HTML_60_70, HTML_EVENT_UNSAFE, HTML_FONT_COLOR_BLUE, HTML_FONT_COLOR_GRAY, HTML_FONT_COLOR_RED, HTML_FONT_COLOR_UNSAFE, HTML_JAVASCRIPT, REFERENCES, SMTPD_IN_RCVD X-Spam-Level: * X-Archive-Number: 200311/43 X-Sequence-Number: 2436 This is a multi-part message in MIME format. ------=_NextPart_000_009D_01C3AF07.CA3727B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable )> onunload above can't call function from PHP, but it called from javascript,= you can create javascript function to call PHP function/file that you wann= a PHP do=20 window.close();"; ?> --------- ----- Original Message -----=20 From: Noel=20 To: pgsql-php@postgresql.org=20 Sent: Tuesday, November 18, 2003 10:33 AM Subject: [PHP] Cancel a query when user leaves a web page Hi all, I have a small problem. Is it possible to cancel a running query when a p= erson leave or pressed the stop button in my web page. I've been thinking about mixing php and javascript. Is this the best way = to go about it? basic out line of my code: ....stuff.... ...stuff The query can take some time. And when the page is left the query is still running on postmaster. Have tried )> The function, close_connection($connection), is defined in the include fi= le, which is the connection is busy, cancels the query and closes the conne= ction. This gives the following error: Resource id #1 Warning: pg_send_query(): 1 is not a valid PostgreSQL link resource in /h= ome/fauxn/public_html/singleAArepeats/test.php on line 11 Any suggestions welcome. Many thanks --=20 Noel Faux Department of Biochemistry and Molecular Biology Monash University Clayton 3168 Victoria Australia ------=_NextPart_000_009D_01C3AF07.CA3727B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

<body=20 onunload(<?close_connection($connection)?>)>

onunload above can't call fu= nction from=20 PHP, but it called from javascript, you can create javascript fun= ction=20 to call PHP function/file that you wanna PHP do 

<?php
// close_connection.php
include(
'connection.php');
global
$connection;

function close_connection(
$connection){
//=20 close_connection here
= //=20 .....
// .....
// .....

}

close_connection(
$connection);
echo
"<SCRIPT>window.close();</SCRIPT>";
?>

---------

<html>

<= ;SCRIPT LANGUAGE=3D"JavaScript">
=
<!-- Begin
function leave()= {
window.open('close_connection.php','','toolbar=3Dno,menubar=3Dno,l= ocation=3Dno,height=3D10,width=3D10');
}
// End -->
</SCRIPT>

<body=20 onunload<= FONT=20 face=3D"Courier New" color=3D#008080 size=3D1> =3D=20 "leave()">

</
body>
</html>

----- Original Message -----
Fro= m:=20 Noel
To: pgsql-php@postgresql.org
Sent: Tuesday, November 18, 2003 1= 0:33=20 AM
Subject: [PHP] Cancel a query when= user=20 leaves a web page

Hi all,

I have a small problem. Is it possible to c= ancel=20 a running query when a person leave or pressed the stop button in my web= =20 page.

I've been thinking about mixing php and javascript. Is this = the=20 best way to go about it?

basic out line of my=20 code:
<html><head>....stuff....</head>
<body&g= t;...stuff
<?php
   =20 $connection =3D pg_connect(host, dbname, user);

   = =20 pg_send_query($connection, "SELECT * FROM blah");

  &nbs= p; //=20 collect the results and display=20 etc..
?>
</body></html>
The query can take some= =20 time.
And when the page is left the query is still running on=20 postmaster.

Have tried
<?php
    include= =20 "functions.php";
    $connection =3D pg_connect(host, d= bname,=20 user);
?>
<html><body=20 onunload(<?close_connection($connection)?>)>
<?php
&nbs= p;  =20 echo $connection;
    pg_send_query($connection, "SELEC= T *=20 FROM blah");

    // collect the results and display= =20 etc..
?>
</body></html>

The function,=20 close_connection($connection), is defined in the include file, which is t= he=20 connection is busy, cancels the query and closes the connection.

T= his=20 gives the following error:

Resource id #1
Warning:=20 pg_send_query(): 1 is not a valid PostgreSQL link resource in=20 /home/fauxn/public_html/singleAArepeats/test.php on line=20 11

Any suggestions welcome.

Many thanks
--=20 Noel Faux Department of Biochemistry and Molecular Biology Monash University Clayton 3168 Victoria Australia
------=_NextPart_000_009D_01C3AF07.CA3727B0--