News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

problem with a chat script php

Started by kahlan, June 17, 2005, 04:33:20 AM

Previous topic - Next topic

kahlan

ok i know my code is kinda sloppy so please attempt to disregard that and try to help me  but i went and redone my chat script now when a person sends a tell to another person the first tell looks like this for example

You told Drathnartest, "test1"

then i send another tell right after that and the db entry changes to be this and is displayed on my screen as ...

Drathnar_Nite`Mare told you, "test1"
You told Drathnartest, "test2"

and if i were to send another one test2 would become Drathnar_Nite`Mare told you

what is wrong with my script why is it always changing the previous tell to display the user that sent it as receiving the tell from themselves? instead of staying as you told $the_person





if ($command1 == 'tell'){

     include("db.php");

    $explodit = explode(" ", $command);
    $the_person = $explodit[1];

    $queryb = mysql_query("SELECT * FROM `character` WHERE Who='y' AND User='$the_person'");
    while ($row = @mysql_fetch_array($queryb))
    {

    $messages=$row["messages"];
    unset($explodit[0]);
    unset($explodit[1]);
    $command = join(" ", $explodit);


        $command2 = $user." told you, \"".$command."\"";
        $messages2 = $messages."<br>\n".$command2;

     $sqlquery2 = "Update `character` SET messages='$messages2' where User='$the_person'";
     mysql_query($sqlquery2);
     }
     mysql_query("SELECT * FROM `character` WHERE Who='y' AND User='$user'");
         while ($row = @mysql_fetch_array($queryb))
    {
    $messages=$row["messages"];
    }

    unset($command2);
    unset($messages2);
    $command = "You told ".$the_person.", \"".$command."\"";
    $messages = $messages."<br>\n".$command;
     mysql_query("Update `character` SET messages='$messages' WHERE User='$user'");
     mysql_close();

}


Advertisement: