if-statement

is_dir and if else outputting syntax error, unexpected T_ELSEIF

Hello everyone, I am having some trouble with an if, else and is_dir; I am trying to create a small script that tells me if the input is a folder or a file, I have looked at: http://us2.php.net/manual/en/function.is-dir.php for a few examples, and none of them seemed to resemble mine, I read a bit on if and else as well, and it looks li...

Grouping ands and ors in a PHP if statement

This is probably a simple answer, but I was curious if you have php code like say this: if($_SESSION['id'] == '000001' || $_SESSION['id'] == '000002') { Could those values be grouped somehow? My thoughts would be something like: if($_SESSION['id'] == ('000001' || '000002')) { Not a huge deal, just wondering if it is possible. If no...

How to use tricks in combination of "IF" conditions?(C# ASP.NET)

I have four checkboxes in my form. I have string variable called "CheckedString". If i check the first checkbox "A" must be assigned to "CheckedString". If i select both first and second checkbox at a time. "AB" must be assigned to "CheckedString". If i select third and fourth checkbox "CD" must be assigned to "CheckedString".So that sev...

If statement in Xcode to determine which HTML page is being loaded by a UIWebView

Hi guys, I have a UIWebView on my interface and I have added a UIToolbar with a next button and previous button. When I press the next button, I want the WebView to load a different HTML page. BUT I also want to run an if statement to determine which HTML page the WebView currently has in it. So For example. If the UIWebView has index...

Why is my if statement not working?

I am trying to check if a gas pump is free for use && full of gas, and then I am trying to make that pump the pump to be used by the cars in a queue. Thread carThreads[]=new Thread[TOTAL_CARS]; try { Pump pump1 = new Pump(); pump1.setName("pump1"); pump1.setFuelAmount(2000); pump1.setState(0); Pump pump2 = new Pum...

How to use isset and null variables in functions

I have a fairly simple question I'm guessing. I have the following code at the beginning of my function, but it must not be correct because it causes the blank to turn blank. If I comment out the IF statement, everything runs fine. What am I doing wrong? Sorry, it's probably very basic... function get_entries($order = 'newest', $slug ...

Nested if-statements without brackets

Hi, following code is given: if (c2-c1==0) if ( c1 != c3 ) {...} How do I interpret this code? The first if-statement comes without {}. Is the code above equal to the following code?: if (c2-c1==0){ if ( c1 != c3 ) {...} } ...

Check if string contains one value or another, syntax error?

I'm coming from a javascript backend to Python and I'm running into a basic but confusing problem I have a string that can contain a value of either 'left', 'center', or 'right'. I'm trying to test if the variable contains either 'left' or 'right'. In js its easy: if( str === 'left' || str === 'right' ){} However, in python I get a ...

Swap if-statements

Hi, I am working on code minimization and enhancement. My question is: is it possible to swap the if statements above without destroying the logic of the code? int c1 = Integer.parseInt(args[0]) ; int c2 = Integer.parseInt(args[1]) ; int c3 = Integer.parseInt(args[2]) ; if (c2-c1==0) if ( c1 != c3 ) Since betwe...

Insert variables to minimize code

Hi, I am facing a strange problem. if ( c2==c1){ c3 *= 2 ; System.out.println( c3 ) ; ..... } I want to insert c3*2 in the println statment. But if ( c2==c1){ System.out.println( c3*2 ) ; gives me a different result. Here is the whole code: public static void main(String [] args) { int c1 =...

using user input such as YES and NO to control program flow in C++

Hi, I'm making a small program that uses a if else statement, but instead of using numbers to control the flow i want to be able to make the control work with with yes and no; for example: cout << "would you like to continue?" << endl; cout << "\nYES or NO" << endl; int input =0; cin >> input; string Yes = "YES"; string No = "NO"; i...