Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    96
    Thanks
    4
    Thanked 0 Times in 0 Posts

    If 'userlevel = 2' PROBLEM! =(

    Alright so I trying something fun with my game... but this doesn't seem to do the trick (trying to make Admin (user level 2) names turn PINK! and have an image beside their names..)

    PHP Code:
    if($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>";$d="<img src='donator.gif' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; }
    if(
    $r['user_level'] = 2) { $r['username'] = "<font color=pink>{$r['username']}</font>";$d="<img src='sexy.gif' title='Admin: They own you.' />"; } 

    Anyone wanna help fix it?

    EDIT:

    It usually turns out that the Admin names are red (they are donators) and the rest for some reason get the sexy image and pink name lol
    Last edited by 2Pacalypse; 08-03-2008 at 10:20 PM.

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 206 Times in 203 Posts
    The = is an assignment operator so you are setting the user_level to 2 in the second if. Use == instead like so:

    PHP Code:
    if($r['user_level'] == 2) { $r['username'] = "<font color=pink>{$r['username']}</font>";$d="<img src='sexy.gif' title='Admin: They own you.' />"; } 
    Dave .... HostMonster for all of your hosting needs

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    = is assignment, == is a test for equality.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #4
    New Coder
    Join Date
    Jul 2008
    Posts
    96
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks so much!


  •  

    Posting Permissions

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