473,698 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1254
*** 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
1589
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 seems to get me any closer to the solution. Below is a program that I am working on for a class project. The original code was provided for us which is what I have below. What we have to do is make the app run so that it allows the user to add...
5
3350
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 printer using a RawPrinterHelper class that i found I believe in the msdn. the class works wonderfully when I send stright text data (in the correctly formated string that the sato printer requires.) but when i go to send a image nothing is...
6
2184
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 Boolean and the main program below. I have overloaded these operator symbols =, ==, !=, !, ||, &&. Now to my question I have some problem with this Class Boolean that I use as
18
1792
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 and the following code throws a "status variable" not found in the inner-most function, even when I try to "global" it. def collect(fields, reducer): def rule(record): status = True
13
5644
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 default 0); TransactionKey is the primary key, CustomerID and AmountSpent are both
0
5569
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
1569
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. Somehow, it does seem that the validate users logic is picking this new code up. Can anyone tell me what I might have missed out? Regards ==================================================>
9
2735
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 in. My business classes are, of course, decorated with the: <System.ComponentModel.DataObject() attribute. So, I drop a GridView on a webform and set its datasource to an ObjectDatasource which in turn is using one of my business logic...
1
7106
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 someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
0
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.