473,387 Members | 1,844 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,387 software developers and data experts.

Help me with this boolean logic

I wrote a piece of boolean logic that doesn't work and I don't know
why. The code should ONLY do something if the session variable is
equal to 900123:

if( ! $_SESSION['SubscriptionID'] == '900123') {
//do some logic
}

However it always returns true. After staring at it for a while, I
realized that the PHP way of doing things is to use the != operator,
instead of putting ! at the front of the entire statement (I've been
doing too much Filemaker scripting). However I can't figure out why
this code shouldn't work. Does anybody have some insight?

Cheers,
Kevin
Aug 13 '08 #1
3 1237
*** Kevin Audleman escribió/wrote (Wed, 13 Aug 2008 08:44:09 -0700 (PDT)):
I wrote a piece of boolean logic that doesn't work and I don't know
why. The code should ONLY do something if the session variable is
equal to 900123:

if( ! $_SESSION['SubscriptionID'] == '900123') {
//do some logic
}
Read the section about operators precedence in the PHP manual:

http://es.php.net/manual/en/language...ors.precedence

Your code equals to:

(!$_SESSION['SubscriptionID']) == '900123'

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Aug 13 '08 #2
Read the section about operators precedence in the PHP manual:
>
http://es.php.net/manual/en/language...uage.operators...

Your code equals to:

(!$_SESSION['SubscriptionID']) == '900123'

--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor en cubitos:http://www.demogracia.com
--
Thank you Alvaro!

Kevin
Aug 13 '08 #3
..oO(Kevin Audleman)
>I wrote a piece of boolean logic that doesn't work and I don't know
why. The code should ONLY do something if the session variable is
equal to 900123:

if( ! $_SESSION['SubscriptionID'] == '900123') {
//do some logic
}
In addition to the other answer: Why is the number quoted? Is the ID
numeric or a string?

Micha
Aug 13 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
5
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this...
6
by: Tony Johansson | last post by:
Hello Experts! I have the user defined class called Boolean that should be handle all kind of logic expression such as if (a && b && c) or if (!a && b && c) osv I have the class definition...
18
by: jslowery | last post by:
I am not completely knowledgable about the status of lexical scoping in Python, but it was my understanding that this was added in a long time ago around python2.1-python2.2 I am using python2.4...
13
by: Slower Than You | last post by:
Well, I think it's complex anyway -- you might not :) TableDef: CREATE TABLE CustTransactions ( TransactionKey int IDENTITY(1,1) NOT NULL, CustomerID int, AmountSpent float, CustSelected bit...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: Fendi Baba | last post by:
I need to implement a login system using Asp.net 2.0 login module( membership provider) with password being case insensitive. I wrote a class Accessmembershipprovider.vb and below is my code....
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.