Page 1 of 1

[SOLVE] Connection Handling problem :)

Posted: Sat Feb 04, 2006 2:11 am
by quocbao
Hi all , i have a problem with php connection handling

Code: Select all

<?

set_time_limit(0);
ignore_user_abort(TRUE);

echo "Start<br>\n";

$i = 1;

while (connection_status() == 0 && connection_aborted() == FALSE)
{
	echo "Line $i<br>";
	flush();
	$i++;
		
	sleep(1);
}

$f = fopen('test.txt' , 'wb');
fwrite($f , 'end');
fclose($f);
exit;

?>
The code is simple , i just want the script echo something while browser still connect and when the browser disconnect ( i press the stop button ) the script will open a file and write something to it .

But when i press the stop button T__T , or PHP stops immediately or it keeps running forever .

Can someone help me ! :( :confused:

Posted: Mon Feb 06, 2006 8:28 am
by quocbao
I think i found the problem :

When i tested this script , i used Apache with PHP4 ( installed as CGI )

Later i tried it with IIS , PHP4 or Apache , PHP4 ( installed as module ) , everything went smoothly

Then there is some limitation with PHP and Apache when PHP is installed as CGI :(