dark dude Posted August 3, 2006 Share Posted August 3, 2006 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 Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 trytry$BannedBy != $Username &&...(Without the single quotes round Username) Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 3, 2006 Share Posted August 3, 2006 I dont get wht there is an exclamation mark?if($BannedBy!='$Username' && $Status=='Game Moderator'){Just out of curiousity and for my own knowledge, can someone tell me? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 3, 2006 Share Posted August 3, 2006 The "!=" operator means "not equal".Ken Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 3, 2006 Share Posted August 3, 2006 Ah, thanks Ken. Quote Link to comment Share on other sites More sharing options...
dark dude Posted August 3, 2006 Author Share Posted August 3, 2006 [quote author=onlyican link=topic=102862.msg408856#msg408856 date=1154611890]trytry$BannedBy != $Username &&...(Without the single quotes round Username)[/quote]That solved it =] Thanks a lot =D Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 Dont quote me on thisin PHPvars 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 showjamie$mynameThis is handy for some scripts Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.