samedi 1 décembre 2018

i need help figuring out this php problem using files and if statemtents

Me and my Teacher have both looked through it and I cant seem to find the error that makes it print "wrong" when the email in the file is the same as the one entered

EMail = $user[0]; echo $UserDet->EMail; $Email = $_GET['email']; $Email = (string)$Email; if($Email == $UserDet->EMail) { echo "correct"; } else { echo "wrong"; } } else { echo "No Account found"; } ?>

C# - What does this '!' mean in front of a command in a if statement?

if (!instruction.Contains(" "))
{
return instruction;
}

What does the '!' mean in front of the command in an if statement?

Thanks

Compiler Error in C - expected ‘;’ before ‘{’ token after ELSE statement

Here’s a newbie question. I’m writing this simple if...else code, but the gcc compiler acuses that the ';' token is missing right after the else expression, even though I’ve never seen any C if...else code examples that includes this specific token before the function’s curly braces. Also, when I include the token after the 'else' function, the terminal outputs both if and else elements, so I’m completely lost here.

Compiler Error:

cclasses.c:15:2: error: expected ‘;’ before ‘{’ token

Code:

#include <stdio.h>
#include <stdbool.h>

int main ()
{
        int x;
        printf("\nEnter with negative or positive int.");
        scanf("%i", &x);

        if (x > 0)
        {
                printf("\nYou've entered positive int: %i\n", x);
        }
        else(x < 0)
        {
                printf("\nYou've entered negative int: %i\n", x);
        }

        printf("\nEND OF PROGRAM.\n");
        return 0;
}

Interpretation and meaning of "a@0==0" in python

I cannot understand the meaning of this condition "((a+0!=0) or (a@0==0))" in the code bellow. This code test if the input year is a leap year.

a = eval(input('Enter a year :'))

if (a%4==0) and ((a+0!=0) or (a@0==0)): print(a,"is a leap year") else: print(a,"is not a leap year")

Thank you for your help.

Unable to create a check condition(using else if condition) in protractor for a element which belongs to multiple classes

There is a scenario where I need to perform an action(delete or add) on a particular element. But that element may belong to different classes and depending on the class. I have to perform the action on that element.

Example: There are 3 classes (class1, class2, and class3). So if that element belongs to the class "class1 and class2" Then 1st it should perform delete action and then add action. But if that element belongs to the class "class3". Then it should only perform add action.

Below is the snippet of my code.

        if(class1.isPresent()) {
            deleteSpecial.click();
            console.log("Class 1 executed");
            addSpecialCard.element(addSpecial.locator()).click();
        } else if(class2.isPresent()) {
            deleteSpecial.click();
            console.log("Class 2 executed");
            addSpecialCard.element(addSpecial.locator()).click();
        } else {
            addSpecialCard.element(addSpecial.locator()).click();
            console.log("Else executed");
        }

In the above way. It always execute the 1st conditon. It never goes to the else if or else condition.

I tried in this way also. But that also didn't work.

if(class1.isDisplayed() || class2.isDisplayed()) {
        deleteSpecial.click();
        console.log("Class 1 executed");
        addSpecialCard.element(addSpecial.locator()).click();
    } else {
        addSpecialCard.element(addSpecial.locator()).click();
        console.log("Else executed");
    }

I tried even doing this using promise. But I don't know, how can I use the else if condition in that. (given that it has to check for 3 classes). Below is the snippet of that.

      class1.isDisplayed().then((result) =>{
        if(result) {
            deleteSpecial.click();
            console.log("Class 1 executed");
            addSpecialCard.element(addSpecial.locator()).click();
        } else {
            addSpecialCard.element(addSpecial.locator()).click();
            console.log("Else executed");
        }
    });

Any help or suggestion will be much appreciated. I have been trying to solve this problem from weeks. But no luck. Thank you in advance.

.setAttribute(id,element.id) is not a function

When i click on a smallDiv i want to add its id to the BigDiv. Unfortunately, my console says that element.setAttribute is not a function. I console log my SmallDiv id and it works when i click on it (in comments). I also tried without the if statement but it doesn't work too.

Here is my code :

var smallDiv = document.getElementsByClassName("small");
var bigDiv = document.getElementsByClassName("big");

for(let i=0;i<smallDiv.length;i++){
smallDiv[i].addEventListener("click",function(){
    if(smallDiv[i].hasAttribute('id')){
    bigDiv.setAttribute('id',smallDiv[i].id);
    //console.log(smallDiv[i].id);
    }
});
};

Thanks for your help !

Nested if loops in For Loop in R to compare conditions

I wanted to compare two conditions & assign a score; I have two vectors one A with some values & B is the timestamp. All I wanted to do is if say value in A is greater than a threshold & the difference in timestamps with its previous one is greater than 1 I should assign a score to C.. I am having trouble executing the following code.

for(i in 2:length(test$B)) {
  if(test$A>15 & (test$B[i]-test$B[i-1])<=4) {
    test$C<-3 
  } else if(test$A<15 & (test$B[i]-test$B[i-1]==1)) {
    test$C<-2 
  } else {
    test$C<-1
  } 
}