Sound like a good headline doesn't it
Hello folks..
I am writing some chat software which uses a meta refresh to read the most current messages stored in the database.
I would also like to store a session variable on the server which stores the time the user logs in. This is then used to display those messages that are written after the user logs in.
However the meta refresh generates new sessions which is not what i want, here is the offending script ..
<?
session_start();
if(!session_is_registered('timestamp')) {
session_register('timestamp');
}
$db_name = 'noticeboard';
$board_id = 5 ; // again for now
$connection = @mysql_connect("localhost", "paulsbooker", "charloTTe")
or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
if(!isset($timestamp)) {
$sql = "SELECT NOW() FROM chat " ;
$result = @mysql_query($sql) or die ("query failed.. mysql_query($sql)");
$row = @mysql_fetch_array($result);
$timestamp = $row[0];
}
$sql = " SELECT chat_name,new_message FROM chat
WHERE board_id = '$board_id'
AND timestamp > '$timestamp' " ;
$result = @mysql_query($sql) or die ("query failed.. mysql_query($sql)");
while($row = @mysql_fetch_array($result)) {
$chat_name = $row['chat_name'] ;
$new_message = $row['new_message'] ;
$message = "\n<".$chat_name." > : ".$new_message ;
$conversation =$message.$conversation ;
}
?>
then some html...
Any suggestions or insights will be kindly received.
Paul