Can someone tell me what is wrong here please: if ($gender != 'Male' OR 'Female' OR 'Unknown'){ die("That Dosn't Work Here Smart Ass HAHA"); }elseif ($gender = 'Male' OR 'Female' OR 'Unknown'){ PHP: Thanks
Hi, Just two simple problems with your use of operators in PHP you do not use OR (in SQL you do), instead you use || to represent this. Also = is an assignment operator, for example when you use $gender = "male", you are assigning the String male to the variable gender. Inside your if statement you need to use a comparison operator, which is an equals sign twice (==). For more on operators, see here it's a really basic and quick lowdown on arithimatic logical and comparison operators in php. Anyway based on what i've said above it would make your statement: if ($gender != 'Male' || 'Female' || 'Unknown'){ die("That Dosn't Work Here Smart Ass HAHA"); } elseif ($gender == 'Male' || 'Female' || 'Unknown'){ //Blah } PHP:
A logical mistake is here. I guess, the operator should be AND not OR for if(). The if() checks if the gender is neither of Male, Female or Unknown and elseif() checks if the gender is either of these there. So && for if() and || for elseif() will be appropriate.
This doesnt work on PHP. The correct syntax is: if ($gender != 'Male' || $gender != 'Female' ||$gender != 'Unknown'){ die("That Dosn't Work Here Smart Ass HAHA"); } else{ //Blah } PHP: Also, for this particular example, the conditions placed on the elseif is redundant.