while ($newmessage = 0) {
$testa = "SELECT * FROM messages WHERE session = '$session' AND time < '$timestamp'";
$testb = mysql_query($testa, $link) or die(mysql_error());
$newmessage=mysql_numrows($testb);
sleep(1);
if ($newmessage > 0) {
header( "location: http://www.domain.com" );}
}
Hi, I have that code. Basically, its for a small two way chat script. That code is within an iFrame and basically should refresh the page when a new message is found in the datatbase.
As you can see this is done by comparing the timestamp of the message and an infinate loop, untill it find a message. However this is not functioning properally. I am unsure where the problem is from. The MySQL is fine, so I guess its either the header or the loop, or both.
I do not think the header works as code is already echoed earlier up on the page. I do not no of another way of doing this though..
Also is the loop setup correctly?
Thanks,