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
Share on other sites

Dont quote me on this
in PHP
vars in double quotes (") come out as vars

Vars in Single Quotes are literal and come out at printed
$myname = "jamie";
echo "$myname<br />";
echo '$myname';

will show
jamie
$myname

This is handy for some scripts
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.