[SOLVE] Connection Handling problem :)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
quocbao
Forum Commoner
Posts: 59
Joined: Sat Feb 04, 2006 2:03 am
Location: HCM,Vietnam
Contact:

[SOLVE] Connection Handling problem :)

Post 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:
Last edited by quocbao on Mon Feb 06, 2006 8:29 am, edited 1 time in total.
User avatar
quocbao
Forum Commoner
Posts: 59
Joined: Sat Feb 04, 2006 2:03 am
Location: HCM,Vietnam
Contact:

Post 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 :(
Post Reply