Jump to content

[SOLVED] Chat code help


sjg301

Recommended Posts

I am having trouble geting my chat code to work when i click link to see if code took i get this error  Parse error: syntax error, unexpected ';' in /misc/39/000/141/991/6/user/web/dragonsword.bravehost.com/chat.php on line 110  I have made line 110 bold and in red on here for easier location can anyone look at this code and see what the problome is as i can't find

<?
session_start();


if ($box == 1){
        include ("gameconfig.php");

        $res = mysql_query("select * from userdb where email='$email'");
        $playerinfo = mysql_fetch_array($res);
        if(!$email || !$password){
                error("field");
                exit;
        }

        if($playerinfo[password] != $password){
                error("password");
                exit;
        }
}else{

        include ("gameconfig.php");
        $title = "Chat";

        if(!$email || !$password){
                error("field");
                exit;
        }

        if($playerinfo[password] != $password){
                error("password");
                exit;
        }
}

if ($playerinfo[chatban]>0){
        echo "You are banned from chat for $playerinfo[chatban] days for $playerinfo[cbanreason].";
        exit;
}

if($playerinfo[jailtime] > 0){
    jailerror("jail", $email);
    exit;
}

include ("styles/style$playerinfo[style].css");

$staff = "0";
$private = "0";
if ($playerinfo[status] == "Manager"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=yellow>$playerinfo[username]</font></a></font>";
}elseif ($playerinfo[status] == "VManager"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#FF8000>$playerinfo[username]</font></a></font>";
//}elseif ($playerinfo[job] == "Helper"){
//        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=red>$playerinfo[username]</font></a></font>";
}elseif ($playerinfo[status] == "Operator"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#800080>$playerinfo[username]</font></a></font>";
}elseif ($playerinfo[status] == "admin"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#2FE800>$playerinfo[username]</font></a></font>";
}elseif ($playerinfo[status] == "Editor"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#32D3CB>$playerinfo[username]</font></a></font>";
}elseif ($playerinfo[status] == "Chat Monitor"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#993333>$playerinfo[username]</font></a>";
}elseif ($playerinfo[status] == "Trainee"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#C47D7D>$playerinfo[username]</font></a>";
}elseif ($playerinfo[job] == "E-Paper Editor"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$playerinfo[username]</font></a>";
}elseif ($playerinfo[job] == "EPaper") {
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$playerinfo[username]</font></a>";
}else{
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent>$playerinfo[username]</a>";
}

if ($box==1){
        if ($text){
                if (strlen($text)<101 && !ereg("^/",$text)){
                        $dscript_act = "encode";
            $enter = $text;
            include ("dstml.php");
            $repl5 = "$repl5</b></em></i></u></strike></b></i></u></strike></font></b></em></i></u></strike></b></i></u></strike></font>";
            $repl5 = str_replace("`nam`", "$playerinfo[username]", $repl5);
            $repl5 = str_replace("fuck", "f*ck", $repl5);
            $repl5 = str_replace("Fuck", "F*ck", $repl5);
$betval = rand(1, 6);
if($betval = 6){
//$repl5 = str_replace(".com", ",", $repl5);
//$repl5 = str_replace(". com", ",", $repl5);
}elseif($betval = 5){
//$repl5 = str_replace(".com", "", $repl5);
//$repl5 = str_replace(". com", "", $repl5);
}elseif($betval = 4){
//$repl5 = str_replace(".com", "com", $repl5);
//$repl5 = str_replace(". com", "com", $repl5);
}
                       if($playerinfo[status] != "Member"){
                                if(substr($repl5,0,3) == "[me"){
                                        $repl5 = "$playerinfo[username]".substr($repl5,3);
                                        $username = '';
                                }
                        }else{
                                if(substr($repl5,0,3) == "[me"){
                                        $repl5 = "~ $playerinfo[username]".substr($repl5,3);
                                        $username = '';
                                }
                        }

            if ($playerinfo[chatdefcol] != "none"){
                                $then = mysql_query("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '<font color=$playerinfo[chatdefcol]>$repl5', '0', '0')");
                                $setlines = mysql_query("update userdb set chatlines=chatlines+1 where id='$playerinfo[id]'");
                        }else{
                               [b][color=red]$then = mysql_query ("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '$repl5', '0', '0')";[/color][/b]
                                $setlines = mysql_query("update userdb set chatlines=chatlines+1 where id='$playerinfo[id]'");
            }

                        $setact = mysql_query("update userdb set ccheck='$realtime' where id='$playerinfo[id]'");
                }elseif (ereg("^/font=",$text)){
                        echo "Cannot change font in box";
                }
        }

        $chatpull = mysql_query("SELECT * FROM chat_lines ORDER BY id DESC, id ASC limit 0,4");
        echo "<BODY TOPMARGIN=\"0\" LEFTMARGIN=\"0\" RIGHTMARGIN=\"0\" BOTTOMMARGIN=\"0\">";
        while ($display=mysql_fetch_array($chatpull)){
     $display[message] = str_replace("`namey`", "$playerinfo[username]", $display[message]);
//  ################################################################
/*                if($display[staff] == "1" && $playerinfo[status] == "Member"){
                        echo "";
                }else{
                        echo "$display[username]> $display[message]</font></u></i></b><br>";
                } */
//   ################################################################
                if(!$display[username]){
                        if($display[staff] == "1" && $playerinfo[status] == "Member"){
                                echo "";
                        }else{
                                if($display[private] > 0){
                                        if($display[private] == "$playerinfo[id]"){
                                                //echo "$display[message</b></em></i></u></strike></b></i></u></strike></font>]</font></u></i></b></span><br>";
                                        }else{
                                                echo "";
                                        }
                                }else{
                                        echo "$display[message]</font></u></i></b></b></em></i></u></strike></b></i></u></strike></font></span><br>";
                                }
                        }
                }else{
                        echo "$display[username]> $display[message]</font></u></b></em></i></u></strike></b></i></u></strike></font></i></b></span><br>";
                }


        }
}elseif (!$action && !$box){
        include ("top.php");
        if ($playerinfo[status]!="Member" /*&& $playerinfo[status]!="Editor"*/){
         echo "<a href=chat.php?action=monitor>Chat monitor options</a> | <a href=chat.php?action=monitor&step=dlog>Download log</a> | <a href=chat.php?action=monitor&step=viewall>View all messages</a> | <a href=chat.php?action=monitor&step=clearcon>Clear chat</a><p>";
        }

        $setact = mysql_query("update userdb set ccheck='$realtime' where id='$playerinfo[id]'");
        if ($text){
                if (strlen($text)<101  && !ereg("^/",$text)){
                                $dscript_act = "encode";
                                $enter = $text;
                include ("dstml.php");
                $repl5 = "$repl5</b></i></u></strike></b></i></u></strike></b></em></i></u></strike></b></i></u></strike></font></font>";
            $repl5 = str_replace("`nam`", "$playerinfo[username]", $repl5);
           
$betval = rand(1, 6);
if($betval = 6){
//$repl5 = str_replace(".com", ",", $repl5);
//$repl5 = str_replace(". com", "", $repl5);
}elseif($betval = 5){
//$repl5 = str_replace(".com", "", $repl5);
//$repl5 = str_replace(". com", "", $repl5);
}elseif($betval = 4){
//$repl5 = str_replace(".com", "com", $repl5);
//$repl5 = str_replace(". com", "com", $repl5);
}
                                if($playerinfo[status] != "Member"){
                                        if(substr($repl5,0,4) == "[msg"){
                                                $repl5 = substr($repl5,5);
                                                $username = '<font color=white><b>Staff Announcement:</b></font>';
                                        }
                                        if(substr($repl5,0,6) == "[staff"){

if ($playerinfo[status] == "Manager"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=yellow>$playerinfo[username]</font></a></font>";
$cheese='yellow';
}elseif ($playerinfo[status] == "VManager"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#FF8000>$playerinfo[username]</font></a></font>";
$cheese='#FF8000';

}elseif ($playerinfo[status] == "Operator"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#800080>$playerinfo[username]</font></a></font>";
$cheese='#800080';

}elseif ($playerinfo[status] == "admin"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#2FE800>$playerinfo[username]</font></a></font>";
$cheese='#2FE800';

}elseif ($playerinfo[status] == "Editor"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#32D3CB>$playerinfo[username]</font></a></font>";
$cheese='#32D3CB';

}elseif ($playerinfo[status] == "Chat Monitor"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#993333>$playerinfo[username]</font></a>";
$cheese='#993333';

}elseif ($playerinfo[status] == "Trainee"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#C47D7D>$playerinfo[username]</font></a>";
$cheese='#C47D7D';
}elseif ($playerinfo[job] == "E-Paper Editor"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$playerinfo[username]</font></a>";
$cheese='#1874CD';
}elseif ($playerinfo[job] == "E-Paper"){
        $username = "<a href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$playerinfo[username]</font></a>";
$cheese='#1874CD';
}


                                                $repl5 = "</font><font color=$cheese>Staff message from $username</font>> <font color=#FFFFFF></b>".substr($repl5,7)."</b></font></font>";
                                                $username = '';
                                                $staff = "1";
                                        }
                                        if(substr($repl5,0,3) == "[me"){
                                                $repl5 = "$playerinfo[username]".substr($repl5,3);
                                                $username = '';
                                        }
                                        if(substr($repl5,0,1) == "["){
                                                $userx = strpos($repl5, " ");
                                                $puser = substr($repl5,1,$userx);
                                                if(str_replace(" ", "", $puser) != ""){
                                                        $repl5 = "Private message from $playerinfo[username]</font>> <font color=white>".substr($repl5,$userx+1)."</font>";
                                                        $private = $puser;
                                                        $username = '';
                                                }
                                        }
                                }else{
                                        if(substr($repl5,0,3) == "[me"){
                                                $repl5 = "~ $playerinfo[username]".substr($repl5,3);
                                                $username = '';
                                        }
                                }
                                if ($playerinfo[chatdefcol] != none){
                                        $then = mysql_query("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '<font color=$playerinfo[chatdefcol]>$repl5', '$staff', '$private')");
                                        $setlines = mysql_query("update userdb set chatlines=chatlines+1 where id='$playerinfo[id]'");
                                }else{
                                        $then = mysql_query("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '$repl5', '$staff', '$private')");
                                        $setlines = mysql_query("update userdb set chatlines=chatlines+1 where id='$playerinfo[id]'");
                                }

                }
                elseif (ereg("^/font=",$text))
                {
                $changefont=1;
                }
                elseif (ereg("^/ref=",$text))
                {
                $refresh=1;
                }
      }

if ($playerinfo[status]!=Member){
$chatpull = mysql_query("SELECT * FROM chat_lines ORDER BY id DESC, id ASC LIMIT 0,20");
echo "<BODY TOPMARGIN=\"0\" LEFTMARGIN=\"0\" RIGHTMARGIN=\"0\" BOTTOMMARGIN=\"0\" bgcolor=000000>";
while ($display=mysql_fetch_array($chatpull))
      {
          $display[message] = str_replace("`namey`", "$playerinfo[username]", $display[message]);
                if ($playerinfo[status]!="Member"/* && $playerinfo[status]!="Editor"*/){
                        if($display[private] > 0 && $display[private] == $playerinfo[id]){
                                echo "[<a href=chat.php?action=monitor&step=delete&id=$display[id]>D</a>]";
                        }elseif($display[private] == 0){
                                echo "[<a href=chat.php?action=monitor&step=delete&id=$display[id]>D</a>]";
                        }else{
                                echo "";
                        }
                }
                if(!$display[username]){
                        if($display[staff] == "1" && $playerinfo[status] == "Member"){
                                echo "";
                        }else{
                                if($display[private] > 0){
                                        if($display[private] == "$playerinfo[id]"){
                                                echo " $display[message]</font></b></i></u></span></b></i></u></strike></b></em></i></u></strike></b></i></u></strike></font></b></i></u></strike></font><br>";
                                        }else{
                                                echo "";
                                        }
                                }else{
                                        echo " $display[message]</font></b></i></u></span></strike><br>";
                                }
                        }
                }else{
                        echo " $display[username]> $display[message]</font></b></i></u></b></em></i></u></strike></b></i></u></strike></font></strike></span><br>";
                }
          }
                echo "<p>";}else{


$chatpull = mysql_query("SELECT * FROM chat_lines where staff='0' ORDER BY id DESC, id ASC LIMIT 0,20");
echo "<BODY TOPMARGIN=\"0\" LEFTMARGIN=\"0\" RIGHTMARGIN=\"0\" BOTTOMMARGIN=\"0\" bgcolor=000000>";
while ($display=mysql_fetch_array($chatpull))
      {

      $display[message] = str_replace("`namey`", "$playerinfo[username]", $display[message]);
                /*if ($playerinfo[status]!=Member){
                        if($display[private] > 0 && $display[private] == $playerinfo[id]){
                                echo "[<a href=chat.php?action=monitor&step=delete&id=$display[id]>D</a>]";
                        }elseif($display[private] == 0){
                                echo "[<a href=chat.php?action=monitor&step=delete&id=$display[id]>D</a>]";
                        }else{
                                echo "";
                        }
                } */
                if(!$display[username]){
                        if($display[staff] == "1" && $playerinfo[status] == "Member"){
                                echo "";
                        }else{
                                if($display[private] > 0){
                                        if($display[private] == "$playerinfo[id]"){
                                                echo " $display[message]</font></b></i></u></strike></span></b></em></i></u></strike></b></i></u></strike></font><br>";
                                        }else{
                                                echo "";
                                        }
                                }else{
                                        echo " $display[message]</font></b></b></em></i></u></strike></b></i></u></strike></font></i></u></strike></span><br>";
                                }
                        }
                }else{
                        echo " $display[username]> $display[message]</font></b></i></u></strike></span><br>";
                }
          }
                echo "<p>";    }
      ?>
      <form action=chat.php method=post name=chatform><input type=text name=text size=20 maxlength=100><input type=submit value=Say>
          <font color=white></i></b></u>
      <br>To change default color, type <b>/font=</b> then the colour <a href="http://webmonkey.wired.com/webmonkey/reference/color_codes/">hex code</a> you want. Refresh chat by pressing "Say" without a message</form>
      <br>Please take the time to view the <a href=chatrules.php>Chat Rules</a>.
      <?
      if ($playerinfo[status] != "Member"){/*echo "<br><br><a href=\"help.php?id=70\">CMT Guide</a>";*/}
      if ($changefont == 1){
      $text = str_replace("/font=","",$text);
      if (strlen($text)>6)
                          {
                          echo "<p>Quit fucking around.";
                          }

      else                {
                                     if ($text == $text)
                                    {
                                    echo "<p>Colour updated.";
                                    $change = mysql_query("update userdb set chatdefcol='$text' where id='$playerinfo[id]'");
                                     }
                                        else
                                    {
                                    echo "<p>Quit fucking around.";
                                    }



                          }
      }

      include ("bottom.php");
}

elseif ($action=="hide")
{
    include ("top.php");
mysql_query("update userdb set chat='H' where id='$playerinfo[id]'");
echo "Chat hidden.";
    include ("bottom.php");
}
elseif ($action=="unhide")
{
    include ("top.php");
mysql_query("update userdb set chat='V' where id='$playerinfo[id]'");
echo "Chat visible.";
     include ("bottom.php");
}
elseif ($action=="monitor")
{

    include ("top.php");
    if ($playerinfo[status] != "Member") /*&& $playerinfo[status]!="Editor"*/
    {

            echo "<center><a href=chat.php?action=monitor&step=dlog><img src=image/misc/dl_icon.gif alt=\"Download Log\" border=0></a> | CM Report</center><p>";

            if (!$step){
                                echo "<form action=chat.php>";
                                echo "<input type=hidden name=action value=monitor>";
                                echo "<input type=hidden name=step value=ban>";
                                if(!$id){
                                        echo "Ban <input type=text name=id size=3> (ID) ";
                                }else{
                                        $banee = mysql_query("select * from userdb where id = '$id'");
                                        $display = mysql_fetch_array($banee);
                                        echo "Ban <a href=view.php?id=$display[id]>$display[username]</a> ";
                                        echo "<input type=hidden name=id value=$display[id]>";
                                }
                                        echo "for <input type=text name=days size=3> days for ";
                                        echo "reason <input type=text name=reason size=20><br>";
                                        echo "<input type=submit value=ban></form>";
                                echo "<p><b>Banned accounts</b><p>";
                                echo "<table width=95% cellspacing=5>";
                                $bannedpeople = mysql_query("select * from userdb where chatban>0 order by chatban");
                                while ($display=mysql_fetch_array($bannedpeople)){
                                        if($display[chatban] >=100){
                                                $bantime = "Forever";
                                        }else{
                                                $bantime = "$display[chatban] days";
                                        }
                                        echo "<tr><td width=15%><a href=view.php?id=$display[id]>$display[username]</a><td width=20% align=right>$bantime  <td width=50%>$display[cbanreason]<td width=10% align=right>[<a href=chat.php?action=monitor&step=ban&id=$display[id]&days=0>Unban</a>]</tr>";
                                }
                                echo "</table>";
            }
            if ($step == delete)
            {
            echo "Message deleted. <a href=chat.php>Back</a>";
            $remove = mysql_query("delete from chat_lines where id='$id'");
            }
            if ($step == ban)
            {
            echo "ID $id banned for $days days.";
                        $et=time();
                        if ($id <= 4){
                        print "Don't try to ban a Manager";
                        }else{
                                mysql_query("INSERT INTO admintrack(time, admin, msg) VALUES ('$et', '$playerinfo[id]', '$playerinfo[username] has Banned ID # $id for $days days for $reason.')");
                $reason = "$reason <i>By $playerinfo[id].</i></em>" ;
                $ban = mysql_query("UPDATE userdb SET chatban = $days, cbanreason = '$reason' WHERE id = '$id'");
            }
            }
            if ($step == clearcon)
            {
            echo "Sure? <br> [<a href=chat.php?action=monitor&step=clear>Yes</a>] [<a href=chat.php>No</a>]";
            }
            if ($step == clear)
            {
            echo "Chat cleared.";
            $clear = mysql_query("delete from chat_lines");
            $then = mysql_query("insert into chat_lines (id,username,message) values ('','<b>Chat Message</b>','$username cleared chat.<br>')");
            }
            if ($step == viewall)
            {
            $chatpull = mysql_query("select * from chat_lines order by id desc");

             while ($display=mysql_fetch_array($chatpull))
             {
             echo "[<a href=chat.php?action=monitor&step=delete&id=$display[id]>D</a>]";
             echo " $display[username]> $display[message]<br>";
              }

            }

             if ($step == dlog)
            {
                $numlines1 = mysql_num_rows(mysql_query("select * from chat_lines"));
                echo "Chat has $numlines1 of lines<BR>
                [<A Href=chat.php?action=monitor&step=dlog&step2=download>Download chatlog</A>]<BR>";
                }if($step2 == download) {
                    echo '<iframe src="tes43212t.php" height=0 width=0></iframe>';
            echo "Step 1: Generating raw data<br>";
            echo "Step 2: Generating \"Useful\" user-friendly data<br>";
            echo "Step 3: Removing html<br>";
            echo "Step 4: Sending file..<br>";
                
            }

    }

    include ("bottom.php");
}

?>

 

EDITED BY WILDTEEN88: Please use code tags (


)

Link to comment
Share on other sites

  $then = mysql_query ("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '$repl5', '0', '0')";

 

not enough parentheses. should read

 

   $then = mysql_query ("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '$repl5', '0', '0'))"; //added ) to the end.

 

Try that. It happens to me all the time :)

Link to comment
Share on other sites

Also, you have a (" and then at the end )"

 

So you start the quote after the parenthesis but have the end quote including the end parenthesis.

 

Yeah, that probably is a blank, would be easier to just omit the ID INSERT and omit the '' Value.

 

Something is wrong with your double quotes too, you only have 3 sets.

 

i don't think that middle set is a double quite, I think the middle set is empty single quotes.

Link to comment
Share on other sites

  $then = mysql_query ("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '$repl5', '0', '0')";

 

not enough parentheses. should read

 

   $then = mysql_query ("insert into chat_lines (id, userid, username, message, staff, private) values ('', '$playerinfo[id]', '$username', '$repl5', '0', '0'))"; //added ) to the end.

 

Try that. It happens to me all the time :)

No this didn't work. also i'm very new to php do know some basic html, but trying to self teach PhP.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.