I am after a script for a chat room which runs on a Flat File Database uising PHP.

I am currently making a news script so that is why I can't make a chat room at the moment.

I was wondering if anyone would be able to temporarily give me the source code to a script (for chatting) just untill I finish my news script.

Because then when I fully finish my news script I will move onto making a chat room.

So if anyone can help me here I would be greatfull.

thanks

    This is just one way to do it (there about 1000 others) but I think its the most basic.

    You could have 2 frames 1 that refreshes every 5 seconds (META refresh) that simply reads a file and outputs it

    $array = file("chatlog.dat");

    while ($i < sizeof($array)) {
    echo $array[$i] . "<br>";
    }

    then you could have a bottom frame or something right to a file...

    ($message comes from input page as well as $username)

    $input = $username . ": " . $message;

    $fp = fopen("chatlog.dat", "w+");

    fputs($fp, $input);

    fclose($fp);

    This is a really simple simple chat room, it doesnt cover errors in input and doesnt cover "garabage collection" when the file gets to big (mabye a cron job to clean out the file everynow and then just a thought). This is really basic I would check out

    http://www.phpbuilder.com/columns/mhall20000621.php3

    They have an article and sample of another chatroom.

      The file never gets too big in that chat room - a message is cropped from the end of the file as each new message is posted.

        thanks for the help

          17 years later
          Write a Reply...