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 
if(isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1 ||  68)
{?>
<li><span class="qmdivider qmdividery" ></span></li>
<li><a class="qmparent" href="javascript:void(0);">ADMIN</a> 

<ul style="width:150px;">
<li><a href="/admin/">Admin Home</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><span class="qmtitle" >Hit Counter</span></li>
<li><a href="javascript:void(0);">Today&nbsp;<?=$hcount?></a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
</ul></li> 
<? } ?>

Any ideas?

Recommended Answers

All 3 Replies

Your problem is with the "|| 68": if(isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1 || 68) . It should be:

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

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

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

- EF

Nice. I never thought about changing it over to that. I appreciate the help. You guys are the best.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.