Jump to content

IF Statement Gone Wrong


dark dude

Recommended Posts

Ok, I have set an If statement on my website so users with the status "Game Moderator" can't unban users banned by another Staff member.

This is the script:
[code=php:0]$query="SELECT * FROM Users WHERE Username='$Unbantarget'";
$result=mysql_query($query);

$Status2=mysql_result($result,$i,"Status");
$BannedBy=mysql_result($result,$i,"BannedBy");

$query="SELECT * FROM Banned WHERE Username='$Unbantarget'";
$result=mysql_query($query);

$num=mysql_numrows($result);

if($BannedBy!='$Username' && $Status=='Game Moderator'){

echo "<span style=color:red>".$Username.", You cannot unban a user you did not ban!<br> Contact the Game Moderator (".$BannedBy.") of the User.";

} else {

if($Status2=='Banned'){

$query="UPDATE Users SET Status='User', BannedBy='', BannedOn='', BannedUntil='', BannedFor='' WHERE Username='$Unbanvictim'";
mysql_query($query);

$query="UPDATE Banned SET BannedFor='$Condition' WHERE Username='$Unbanvictim' && BanTime='$num'";
mysql_query($query);

echo "User ".$Unbantarget." has been successfully unbanned!";

} else {
echo "Typo error? Stupidity? Either way, the user isnt banned";
}
}[/code]

However, when I debugged this by trying to unban a user I had banned, it came up with the message "Test, You cannot unban a user you did not ban!
Contact the Game Moderator (Test) of the User."


What's going on? o.O
Link to comment
https://forums.phpfreaks.com/topic/16447-if-statement-gone-wrong/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.