Solved

Help with PHP condition

Posted on 2011-09-15
4
309 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use embargo Date/time in php 29 37
tomcat startup error 5 63
Presenting past 6 months bug 7 27
PHP Installer 5 23
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
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…
This video teaches users how to migrate an existing Wordpress website to a new domain.

770 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