944,131 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1339
  • PHP RSS
Nov 3rd, 2009
0

if isset ==

Expand Post »
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.
PHP Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 21
Solved Threads: 31
Posting Pro in Training
CFROG is offline Offline
405 posts
since Jul 2009
Nov 3rd, 2009
1
Re: if isset ==
Your problem is with the "|| 68": if(isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1 || 68) . It should be:

php Syntax (Toggle Plain Text)
  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:

php Syntax (Toggle Plain Text)
  1. if(isset($_SESSION['user_id']) && ($_SESSION['user_id'] == 1 || $_SESSION['user_id'] == 68))

- EF
Last edited by EvolutionFallen; Nov 3rd, 2009 at 10:46 pm.
Reputation Points: 40
Solved Threads: 31
Junior Poster
EvolutionFallen is offline Offline
198 posts
since Aug 2009
Nov 3rd, 2009
0
Re: if isset ==
Nice. I never thought about changing it over to that. I appreciate the help. You guys are the best.
Reputation Points: 21
Solved Threads: 31
Posting Pro in Training
CFROG is offline Offline
405 posts
since Jul 2009
Nov 3rd, 2009
0
Re: if isset ==
No problem =)
Reputation Points: 40
Solved Threads: 31
Junior Poster
EvolutionFallen is offline Offline
198 posts
since Aug 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Age Calculation
Next Thread in PHP Forum Timeline: Deleting rows





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC