473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

AND within IF statement

hi,

i have the following:

Expand|Select|Wrap|Line Numbers
  1. if(!isset($_POST['submit'])  AND ($_POST['fac'] ="ALL")))
  2.  
but i think the syntax is wrong. could someone help?

thanks in advance,
geebee
Feb 11 '09 #1
4 1137
hoopy
88
I always use && and syntax as follows:

Expand|Select|Wrap|Line Numbers
  1. function aFunction($a)
  2. {
  3.   return false;
  4. }
  5.  
  6. function bFunction($b)
  7. {
  8.   return true;
  9. }
  10.  
  11. if( !aFunction($a) && bFunction($b) )
  12. {
  13.   echo("Condition met.");
  14. } else {
  15.   echo("Condition failed.");
  16. }
So i guess in your case it would be something like:

Expand|Select|Wrap|Line Numbers
  1. if( !isset($_POST['submit']) && $_POST['fac'] == "ALL" )
You were using = instead of ==

Cheers
Feb 11 '09 #2
Markus
6,050 Expert 4TB
Remember '=' is an assignment operator and '==' is a comparison operator.

Also '===' is a comparison operator which checks for the type of the variable, too.
Feb 11 '09 #3
nathj
938 Expert 512MB
@geraldjr30
You simply have one too many closing brackets.
Feb 13 '09 #4
Atli
5,058 Expert 4TB
Even tho this doesn't matter in this case, it is worth noting that even tho the AND and && operators seem work the same, && has a higher precedence, so exchanging them may actually change the result of an expression.
(See PHP: Operator Precedence)

For example:
Expand|Select|Wrap|Line Numbers
  1. $var = true && false; // $var == false
  2. $var = true and false; // $var == true
Feb 13 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: michi | last post by:
Hello there... Can anybody tell me what is the difference when I excecute a sql statement within pl sql with/without "execute immediate" statement Thanks Michi :)
2
by: Mark Davies | last post by:
Hi all, I think I have the right group, if I don't then I do apologize. My problem is that I'm trying to run a SQL script within a VB Environment. The actual program is WISE Installer, but I'm...
2
by: M Wells | last post by:
Hi All, This seems like a tricky question to me. I have a Stored Procedure that encapsulates a number of updates to various tables within a transaction. However, at a later part of the...
6
by: Cade Perkins | last post by:
How can the CDATA ending delimiter "]]>" be represented within a CDATA section itself? Consider an XML document that is intended to contain an embedded, uninterpreted XML example. Generally,...
4
by: Klemens | last post by:
I want to do runstats within an open transaction to get best optimization for current distribution but in the past I have recognized that runstats had no effect on the next Statements within that...
4
by: bizt | last post by:
Hi, I want to find an easy way to select only rows within a certain range when I do a select. Im sure I have seen this done with a SELECT statement but cant remember if or how it was done. Can...
3
by: Aaron | last post by:
Hi, It is possible to establish relationships between tables within a dataset and this allows some useful features. For example, given a row from a table you can use GetParentRow,...
8
by: ms news group | last post by:
What happens if exception is thown within a fixed block? Will the pinned memory buffer get unpinned? and if the pinning pointer points to a managed memery buffer allocated within the throwing...
5
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi, I have a component where I need to have thread-safe access to a list. Operations on the list are done in critical sections (lock (lockObject) { ... } ) in the usual way, to make sure that no...
2
by: ianmcdonagh | last post by:
Hi folks, I'm looking to pick everyone's brains. I have a cursor, with over 200 columns in the select. I am using a case in one of the columns which I'm retrieving, and want to issue an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.