Log in

View Full Version : chat problem



Demonicman
09-29-2007, 08:44 AM
please tell me whats wrong with the following coding:

<?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!

Demonicman
09-29-2007, 01:34 PM
anyone??

djr33
09-29-2007, 06:00 PM
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>')");