Jump to content


Several questions regarding chat script

  • Please log in to reply
No replies to this topic

#1 tomfmason

  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 20 July 2006 - 01:05 AM

Ok I have several questions regarding a live support Script that I am creating. Here is the code that I have so far. The layout is very simple. This is just for testing purposes.

The chat login

if (isset($nick)) {
   if (empty($nick)) {
       $error = "nick";
$sql = mysql_query("INSERT INTO chat(nick) VALUES('$nick')") or die (mysql_error());

if (!$sql) {
    $error = "sql";
$filename = "$nick.html";
$handle = fopen($filename, "x+b");
$body = "<meta http-equiv=\"refresh\" content=\"2\">
<meta name=\"robots\" content=\"noindex\">
 Welcome <b>$nick</b>, an operator will be with you shortly.
<!--Start of chat-->
<!--end of chat-->
fwrite($handle, $body);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

<p><h3>Please Enter your nick name</h3></p>
if ($error == "nick") {
    echo "You did not enter a nick name";
if ($error == "sql") {
    echo "Something when wrong with the MySQL query.";
<form action="enter_chat.php" method="post">
<input type="text" name="nick" size="20">
<input type="submit" name="submit" value="Submit">


ok I guess I will start with the questions about this script.

First, how can I retrieve the chat_id from the data base so that I may create a html file like this $nick.$chat_id.html

Second, is a refresh rate of 2 seconds to much? Can I make it refresh, on both the client side and operator side, when a new line is added?

Third, when I have enough messages where you need to scroll down to see the last message. Every time the page refreshes it starts me over at the top line again. Is there a way that, when it refreshes, I can make it go to the bottom of the html file.


Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users