I could be wrong but your delete query looks a little funky. Check to make sure there is actually chat messages to be displayed in your DB.
T
: Hi, I'm implementing a chat I found on the web (opensource), but I've made some changes. Mainly in the frame where the messages are shown but now no messages show at all. I've checked the code lots of times and cant figure out what's the problem. If anyone sees the problem please help me. Thanks.
:
:
:
: $query = "UPDATE users SET active = 'y', sent_on = DATE_ADD(NOW(), INTERVAL $diff_timezone HOUR) WHERE username = '$username'";
: do_the_query($chat_db, $query);
:
: $q = "SELECT * FROM users WHERE username='$username'";
: $r = do_the_query($chat_db, $q);
:
: /* delete old messages from our db */
: $sent_on = date("YmdHis", time() - 60 * 60 * 24); /* 24 hours ago */
: $query = "DELETE FROM msg WHERE sent_on < '$sent_on'";
: do_the_query($chat_db, $query);
:
: echo "<HTML>";
: echo "<HEAD>\r\n";
: echo "<LINK REL=\"stylesheet\" HREF=\"../css/estilo.css\" TYPE=\"text/css\">\r\n";
: echo "</HEAD>\r\n\r\n";
:
: echo "<BODY BGCOLOR=\"$gray\" class=\"rodape\">";
: //echo "<FONT FACE=\"arial, helvetica, verdana\">\r\n";
: while($r["active"] == 'y'){
: $query = "SELECT username, color, msg, HOUR(sent_on) AS hour, MINUTE(sent_on) AS minutes, SECOND(sent_on) AS seconds FROM msg ORDER BY sent_on desc LIMIT 1";
: $result = do_the_query($chat_db, $query);
: $row = mysql_fetch_array($result);
:
: switch ($row["color"]) {
: case "1":
: $colore = $lightgreen; /* lightgreen */
: break;
: case "2":
: $colore = $yellow; /* yellow */
: break;
: case "3":
: $colore = $red; /* red */
: break;
: case "4":
: $colore = $green;/* green */
: break;
: case "5":
: $colore = $blue; /* blue */
: break;
: case "6":
: $colore = $brown;/* brown */
: break;
: case "7":
: $colore = $violet;/* violet */
: break;
: case "8":
: $colore = $darkyellow; /* light red */
: break;
: case "9":
: $colore = $black;/* black */
: break;
: default:
: $colore = $black; /* Black (by default) */
: break;
: }
: $hour = ($row["hour"] < 10 ? "0" . $row["hour"] : $row["hour"]);
: $minutes = ($row["minutes"] < 10 ? "0" . $row["minutes"] : $row["minutes"]);
: $seconds = ($row["seconds"] < 10 ? "0" . $row["seconds"] : $row["seconds"]);
:
: /* which kind of message is this? */
: if ($row["username"] == "") {
: echo "<FONT COLOR=$black SIZE=2>[" . stripslashes($row["msg"]) . " entrou no chat - $hour:$minutes:$seconds]</FONT>\r\n";
: }
: else {
: echo "<FONT COLOR=$black SIZE=2>($hour:$minutes:$seconds)</FONT>\r\n";
: echo "<FONT COLOR=$colore SIZE=2><B>[" . stripslashes($row["username"]) . "] :</B> " . stripslashes($row["msg"]) . "</FONT>\r\n";
: }
:
:
: mysql_free_result($result);
:
: /* this user is active: save it! */
: $query = "UPDATE users SET active = 'y', sent_on = DATE_ADD(NOW(), INTERVAL $diff_timezone HOUR) WHERE username = '$username'";
: do_the_query($chat_db, $query);
: $r = do_the_query($chat_db, $q);
: }
: //echo "</FONT>";
: echo "</BODY>";
: echo "</HTML>\r\n";
:
: