Results 1 to 3 of 3

Thread: chat problem

  1. #1
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default chat problem

    please tell me whats wrong with the following coding:
    PHP Code:
    <?php
    if ($_GET[view] == 'banuserc') {
    $ID=$_GET[ID];
        print 
    "<center>Ban user from the chatroom.<br></center>";
        print 
    "<form method=post action=admin.php?view=banuserc&step=banu>Ban User ID <input type=text size=3 name=banu value='$ID'> <input type=submit value=Ban></form>";
        if (
    $_GET[step] == banu) {

    $banu=$_POST[banu]; 
        
    $banu str_replace($remove_these"""$banu");
        
    $banu htmlspecialchars($banu);
            if (
    $banu == 1) {
                print 
    "No Banning the owner.";
                
    end;
            } else {
    $currentb mysql_fetch_array(mysql_query("select * from km_users where ID='$banu'"));

    $uname $currentb['playername'];

    $baninfo mysql_fetch_array(mysql_query("select * from banned where user='$currentb[playername]'"));

    $bname $baninfo['user'];
            if (
    $uname != $bname) {
                
    mysql_query("UPDATE km_users SET status2='Banned', status4='Banned' WHERE playername='$currentb[playername]'");
                print 
    "You Banned ID: $banu and User: $currentb[playername] from the chatroom.";
                            
    mysql_query("insert into chat (chat) value('<font class=me style=\"color: #00FFFF;\">Admin has banned <?php print \"$currentb[playername]\"; ?> from chat!</font>')");
    mysql_query("insert into admin_logs (who, what) values($userstats3[ID],'$userstats3[playername] banned user ID $banu from the chat.')");
            } else {
    mysql_query("UPDATE km_users SET status2='Banned', status4='Banned' WHERE playername='$currentb[playername]'");
                print 
    "You Banned ID: $banu and User: $currentb[user] from the chatroom.";
                            
    mysql_query("insert into chat (chat) value('<font class=me style=\"color: #00FFFF;\">Admin has banned <?php print \"$currentb[user]\"; ?> from chat!</font>')");
    mysql_query("insert into admin_logs (who, what) values($userstats3[ID],'$userstats3[playername] banned user ID $banu from the chat room.')");
                }
            }
        }
    }
    for some reason in chat its only posting Admin has banned from chat!

    it should say Admin has banned (insert any username here) from chat!
    http://www.insanecombat.com << bored? check out ma game

  2. #2
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    anyone??
    http://www.insanecombat.com << bored? check out ma game

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's inserting this line directly into the database:
    mysql_query("insert into chat (chat) value('<font class=me style=\"color: #00FFFF;\">Admin has banned <?php print \"$currentb[playername]\"; ?> from chat!</font>')");

    In other words, it's inserting the text of <?php and ?>. Not PHP code per se.

    PHP code only works as PHP if it is executed at the time the script first runs. The only other way is if you later pass it through exec()... but that's not a good idea, nor needed.

    Assuming you just want to store it in the DB, here:
    mysql_query("insert into chat (chat) value('<font class=me style=\"color: #00FFFF;\">Admin has banned '.$currentb[playername].' from chat!</font>')");
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •