A little PHP coding help please

By Dave - February 22, 2013

Hi Kurt, 

Your code looks good.  What is displayed when you "View Source" in the browser?

Sometimes when I'm working on something I start simple (even now) to make sure things are working, like this:

<?php if ($CURRENT_USER): ?>
  Current User is logged in.
<?php else: ?>
  No one is logged in.
<?php endif ?>

Let me know if that works and what "view-source" shows (does it show the includes you expected, PHP code, errors, or something else? 

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

Hi Kurt,

The code looks good to me, the only change I would suggest is adding an @ to $CURRENT_USER to stop it displaying an error if no one is logged in:

<?php include 'include/header_inc.php' ?>
<?php if (@$CURRENT_USER): ?>
  <?php include 'include/member_navigation_inc.php' ?>
<?php else: ?>
  <?php include 'include/navigation_inc.php' ?
<?php endif ?>

I would check that your not accidentally including navigation_inc.php below the if statement, or that it isn't being included in member_navigation_inc.php.

If neither of these are the issue could you attach the three files to a post so I can take a look at  your code?

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Dave,

Thanks for the tip...it makes a lot of sense.

I don't know what was going on but I tried your example and everything worked as expected, then reloaded my original code and it worked as expected.

Thanks again,

Kurt

CMSB Rocks!
Thanks,
Kurt