Solved

Help with PHP condition

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Date comparison to same 'wednesday' of previous year 3 28
Making exceptions for ValidationAttribute 2 23
help thx 6 20
syntax error, unexpected '?' in phpunit 5 22
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

713 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