Kevin K
Kevin K

Reputation: 113

Why aren't my conditional statements working in php?

This code will run right out of the box, the issue is that it keeps hittign the "pvp" cconditional statement rather than the "account_name" statement... and clearly gw2action is "account_name"....

Upvotes: 0

Views: 32

Answers (2)

Abhijith Sasikumar
Abhijith Sasikumar

Reputation: 15010

You are using the assign operator inside an elseif condition. It always returns a true, I think. You have = the assignment operator, == the 'equal' comparison operator and === the 'identical' comparison operator.

this answer may help.

Upvotes: 0

peanut
peanut

Reputation: 121

Use == when comparing values, one = is assignment and == is is used to compare the value of the variable on the left to the string in this case on the right.

So if($gw2action = "pvp") is actually assigning the value of pvp to $gw2action, it should be if($gw2action == "pvp") etc

Upvotes: 1

Related Questions