if isset ==

Thread Solved

Join Date: Jul 2009
Posts: 208
Reputation: CFROG is an unknown quantity at this point 
Solved Threads: 14
CFROG's Avatar
CFROG CFROG is offline Offline
Posting Whiz in Training

if isset ==

 
0
  #1
23 Days Ago
I'm trying to display a menu option only for certain session id's and for some reason it displays for ALL session id's ... not just the ones i have indicated. Not too sure why it's doing this, it all looks okay to me.
  1. <?PHP
  2. if(isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1 || 68)
  3. {?>
  4. <li><span class="qmdivider qmdividery" ></span></li>
  5. <li><a class="qmparent" href="javascript:void(0);">ADMIN</a>
  6.  
  7. <ul style="width:150px;">
  8. <li><a href="/admin/">Admin Home</a></li>
  9. <li><span class="qmdivider qmdividerx" ></span></li>
  10. <li><span class="qmtitle" >Hit Counter</span></li>
  11. <li><a href="javascript:void(0);">Today&nbsp;<?=$hcount?></a></li>
  12. <li><span class="qmdivider qmdividerx" ></span></li>
  13. </ul></li>
  14. <? } ?>
Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 47
Reputation: EvolutionFallen is an unknown quantity at this point 
Solved Threads: 8
EvolutionFallen EvolutionFallen is offline Offline
Light Poster
 
1
  #2
23 Days Ago
Your problem is with the "|| 68": if(isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1 || 68) . It should be:

  1. if(isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1 || $_SESSION['user_id'] == 68)

It's like you're asking if(68) , which will of course return true. You need to compare the 68 to $_SESSION['user_id']

Also, you may want to add another set of parenthesis to group the last two logical operations together:

  1. if(isset($_SESSION['user_id']) && ($_SESSION['user_id'] == 1 || $_SESSION['user_id'] == 68))

- EF
Last edited by EvolutionFallen; 23 Days Ago at 10:46 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 208
Reputation: CFROG is an unknown quantity at this point 
Solved Threads: 14
CFROG's Avatar
CFROG CFROG is offline Offline
Posting Whiz in Training
 
0
  #3
23 Days Ago
Nice. I never thought about changing it over to that. I appreciate the help. You guys are the best.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 47
Reputation: EvolutionFallen is an unknown quantity at this point 
Solved Threads: 8
EvolutionFallen EvolutionFallen is offline Offline
Light Poster
 
0
  #4
23 Days Ago
No problem =)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC