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 ...
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...
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";
}
...
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.
...
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 do I use an "OR" vs a || in a ColdFusion cfif 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 ...
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...
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 ...
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...
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 ...
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)
...
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='' ...
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?
...
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;
}
...
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
...
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...
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...
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...
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?
...