Solved

Help with PHP condition

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

Expert Comment

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
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 tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 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

19 Experts available now in Live!

Get 1:1 Help Now