Solved

Help with PHP condition

Posted on 2011-09-15
4
306 Views
Last Modified: 2012-05-12
Hi,

I have the attached code condition but it is not working properly:

I want to do the action if ANY of both conditions are true:

if ( is_user_logged_in() OR $_SESSION['count'] <= 3 )

What is wrong here? why not working fine ?

Thanks.

<?php if ( is_user_logged_in() OR $_SESSION['count'] <= 3 )  {
echo "<h1 ><a class='ta'  title='Permalink to $ltitle' href='$url' target='_blank'>$ltitle</a></h1>"; 
}
else {
echo "<h1 ><a class='ta'  title='Permalink to $ltitle' href='/registration'>$ltitle</a></h1>";  
}
?>

Open in new window

0
Comment
Question by:Fernanditos
  • 2
4 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36546465
I don't see an obvious problem.  What error message or result are you getting?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36546476
On http://www.php.net/manual/en/language.operators.logical.php , all the operators are shown as lower case.  ??
0
 
LVL 8

Accepted Solution

by:
PranjalShah earned 500 total points
ID: 36546566
I am not sure if this would help but try changing OR to ||


if ( is_user_logged_in() || $_SESSION['count'] <= 3 )
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 36547685
try this one, will work

<?php if ( (is_user_logged_in()) || ( $_SESSION['count'] <= 3) )  {
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now