Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I tried a PHP chat script that has

Status
Not open for further replies.

hisham

IS-IT--Management
Nov 6, 2000
194
I tried a PHP chat script that has an auto cleaning of old chat text by using:

function ShowAddPosts() {

global $HTTP_SESSION_VARS;
global $chat;
global $nick;
global $timeoutseconds;
global $timestamp;
global $timeout;
global $skin;
$activedir = "./style/";
@chdir($activedir);
$timeoutseconds = 250; // Timeout value in seconds
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;

And the following query:

$chat = strip_tags($chat,'<i><b><a>');


if(!empty($chat)) {

$strQuery = &quot;insert into chatScript values(0, '$chat','$nick','$timestamp')&quot;;
mysql_query($strQuery);
}

$strQuery = (&quot;DELETE FROM chatScript WHERE timestamp<$timeout&quot;) or die(&quot;$useronline $base DELETE Error&quot;);
mysql_query($strQuery);

This work while the browser is opened, but if the user shutdown the browser, the old chat text will not delete from the Mysql Table.
How can I delete the old chat text when user shut down the browser?
The complete code:
 
You could implement an logout function which could invoke your deletion, but there is no way to deterministically enforce the logout.

What you might do is implement a garbage collection routine which performs the deletion when a user begins a chat session and periodically throughout the chat session. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top