if-statement

Separate clauses of an if statement?

Is there any way to have multiple clauses in an if() statement? For instance: if( ($username=='textUser' && $role=='admin') || ($admin=='yes')) { // If the username AND role are set to admin OR if the admin is set to 'yes' } else { // Neither clauses of the if statement are true } Perhaps this is actually the correct code, i ...

Why does this if statement fail in bourne shell?

I'm learning shell scripting but I can't work out this error, any help much appreciated. #!/bin/sh LOCATION=/tmp/loc PROXY=http://wwwproxy.unimelb.edu.au:8000 http_proxy=$PROXY; export http_proxy echo "Installing into" $LOCATION if [ ! -d $LOCATION ]; then mkdir $LOCATION; fi if [ ! -d $LOCATION/packages ]; then mkdir $LOCATION/packag...

If statement returning both true and false in PHP

the following statement returns "do actions!what2" when run. What's going on here? it seems like both true and false are being returned! if (md5($email) == $emailHash) { echo "do actions!"; } else { echo "what2"; } ...

How to make this if statement shorter?

Can I make this statement shorter? if(abc=='value1' || abc=='value2' || abc=='value3') {//do something} to make it look similar to this: if(abc=='value1' || 'value2' || 'value3'){//do something} Thanks. ...

jquery help with if statement

I'm trying to scale images that have a width greater than 100. I'm using the code below, but it scales images that are even below 100px... What am I doing wrong? if($(".image-attach-body")) { if($(".image-attach-body a")) { $(".image-attach-body a").each(function() { var width = $("span span img").width(); ...

When to use || vs. OR in ColdFusion in a <cfif>?

When do I use an "OR" vs a || in a ColdFusion cfif statement? ...

No result in LINQ query gives Object reference not set to an instance of an object in IF ELSE statement.

I have the following code: DataClasses1DataContext db = new DataClasses1DataContext(); var UserInfo = db.Users.FirstOrDefault(u => u.Email == TextBox1.Text); if (UserInfo.Email != null) { Label2.Text = "Email is not null"; } else { Label2.Text = "Email is ...

Java: Checking contents of char variable with if condition

Hello, I have a char variable that is supposed to contain either a Y,y,n or N character, I want to test if it does not contain it, then display an error message and exit the program. This is the code I am using; if (userDecision != 'Y' || userDecision != 'y' || userDecision != 'n' || userDecision != 'N') { Syste...

How to do an if statement on a function in PHP?

I just realized that you can't just use an if statement on a function, for example this doesn't work: function sayHello() { echo "Hello World"; } if(sayHello()) echo "Function Worked"; else echo "Function Failed"; I also saw that a function can't be put as the value of a variable. So how can I do an if statement to check ...

If statement question iphone?

I am creating a game where where you complete shapes and the area gets filled in. However, if there is an enemy bird within your shape, it will not fill in. I want to make it so that if you do trap a bird within your shape, you will lose a life. How can I write an if statement that pretty much says if the below code doesn't take place...

SELECT SQL table retrieved by an IF statement

Hella all, What I want to do is something like that, I will have an SQL table depending on my parameter, DECLARE @find varchar(30) SET @find = 'no' SELECT * FROM ( if @find = 'yes' ( SELECT * FROM myTable WHERE ID= '5882' ) ELSE ( SELECT * FROM myTable WHERE OLD_ID= '5882' ) ) X This is ...

Can I use IF multiple times to switch between multiple options in PHP?

hey i got 9 type on my web. i have to set different keywords each type. with this script; if ($type = movie) { $yazdir = "DVDRip, DVDScr"; } elseif ($type = game) { $yazdir = "Full Version, Patch"; } i can write keywords for two type. how to repeat this correctly for other types? (echo paramether must be $yazdir) ...

Sql Query With Select and IF

here is my table description: Table Name : Orders Columns : ID, NO, Quantity, Base, Code First my query should check the value of Code, if value of Code is 'B' then OUTPUT VALUE should be Code+Base if it is not 'B' then OUTPUT VALUE should be Code+Quantity the obtained rows again will be filtered by using where clause where ID='' ...

C macro: #if check for equality

Is there a way to do check for numerical equality in macros? I want to do somethign like #define choice 3 #if choice == 3 .... #endif #if choice == 4 ... #endif Does C macros have support for thigns like this? ...

It is possible to include Php variables or URL in Javascript in an If-statement?

I want to make some thing like this my-php-file.php $lang = 'es'; my-js-file.js if ($lang == es) { something-magical-happens; } or like this: if (URL == www.mydomain.com/index.php?lang=es) { something-magical-happens; } ...

bash : Multiple Unary operators in if statement

hello, Is it possible to have multiple unary operators in if statements.. Here is the code snippet which is giving me error. Please correct the code here. if [ -f $input_file ] -a [ -f $output_file ] -a [ -f $log_file ] ] then ### Some Code here fi Thanks Kiran ...

'if' scenario in an equation. How do I implement it?

Hey guys, Basically I've been trying to make a working hours calculator and I've run into a problem. When the start time's value is greater than the finish time (eg. start is 23 and finish is 19), the result comes up as a negative. So what I want it to do in that scenario is to then multiply the negative number by -1 to make it positi...

comparison between point and integer

Right, basically I want to add two numbers together. It's for a working hours calculator and I've included parameters for a night shift scenario as an if statement. However, it now mucks up the day shift pattern. So I want to sort out that if the start time is below 12, then it'll revert to the original equation shown in the code instead...

Tidy up if statement - can an object not instantiated be in an AND operator

Can I put an object.property which hasn't been instantiated on the right hand side of an 'AND' operator if I know that the left hand side will fail but if the left side passes the right side will be instantiated? In the example below the first if/else statement sets up the other if statement for the above question. Although I've tested...

What's the syntax for .bat?

if "%OS%"=="Windows_NT" @setlocal ... if "%OS%"=="Windows_NT" @endlocal Does the above basically mean this: if(OS == 'Windows_NT'): ... endif I've curious what's setlocal for ? EDIT Now the only uncertain is:how do bat identify the endif? ...