Okay, here's my problem in a nutshell:
I'm trying to setup up a new chatmode for my chat site, called
"streaming". Basically, it will use flush to keep the output window
alive and post messages automatically as they're made. I've had a heck
of time trying to set this up and I can't seem to even keep the window
alive for any longer than the sleep() calls for, which I have set to
sleep(5);. A little snippet:
// output the messages from the database
$outres = mysql_query("select * from $message_table
where room = '$roomname' AND timestamp > $time
AND ( (target = '$name' OR target = '')
OR (target != '' AND sender = '$name') )
order by timestamp", $dblink);
if($outres == FALSE) {
print "error in mysql query to collect messages";
}
if(mysql_num_rows($outres) > 0 ) {
if ($scrollback_type == "Messages") {
$seek = max(0, mysql_num_rows($outres) - $scrollback);
mysql_data_seek($outres, $seek);
}
flush();
while($row = mysql_fetch_array($outres)) {
output_message($row);
}
sleep(5);
} else {
print "<center>No new messages</center><hr size=1>\n";
}
mysql_free_result($outres);
Why isn't this working? I'm totally new to using flush, but this seems
to be okay to me. Can anyone help?
I'm trying to setup up a new chatmode for my chat site, called
"streaming". Basically, it will use flush to keep the output window
alive and post messages automatically as they're made. I've had a heck
of time trying to set this up and I can't seem to even keep the window
alive for any longer than the sleep() calls for, which I have set to
sleep(5);. A little snippet:
// output the messages from the database
$outres = mysql_query("select * from $message_table
where room = '$roomname' AND timestamp > $time
AND ( (target = '$name' OR target = '')
OR (target != '' AND sender = '$name') )
order by timestamp", $dblink);
if($outres == FALSE) {
print "error in mysql query to collect messages";
}
if(mysql_num_rows($outres) > 0 ) {
if ($scrollback_type == "Messages") {
$seek = max(0, mysql_num_rows($outres) - $scrollback);
mysql_data_seek($outres, $seek);
}
flush();
while($row = mysql_fetch_array($outres)) {
output_message($row);
}
sleep(5);
} else {
print "<center>No new messages</center><hr size=1>\n";
}
mysql_free_result($outres);
Why isn't this working? I'm totally new to using flush, but this seems
to be okay to me. Can anyone help?