...

View Full Version : Resolved IF, AND, OR statements



myfayt
12-13-2010, 08:01 PM
Is there any reason for why this isn't working? It should be

IF contype is equal to Question, AND question2 is blank, OR answer1 is blank, OR answer2 is blank, etc.

I need to see if contype is question, and need to see if any fields are blank. But it isn't accepting it.


if (($contype == 'question') && $question2 == '' || $answer1 == '' || $answer2 == '' || $answer3 == '' || $answer4 == '' || $answer5 == '' || $answer6 == '' || $answer7 == '' || $answer8 == '') {

DJCMBear
12-13-2010, 08:26 PM
Might be a long shot but have you tried this?



if (($contype == 'question') && ($question2 == '' || $answer1 == '' || $answer2 == '' || $answer3 == '' || $answer4 == '' || $answer5 == '' || $answer6 == '' || $answer7 == '' || $answer8 == '')) {

Rowsdower!
12-13-2010, 08:35 PM
I think this is what you meant to do:
if (($contype == 'question' && $question2 == '') || $answer1 == '' || $answer2 == '' || $answer3 == '' || $answer4 == '' || $answer5 == '' || $answer6 == '' || $answer7 == '' || $answer8 == '') {

Your parenthesis closed before the && part rather than after that particular check...

Unless DJCMBear's string is correct in that every case should have contype equal to "question". It's hard to determine that based on what you wrote though.

Hmm, now that I re-read it with DJCMBear's method in mind I think that he hit what you are after.

myfayt
12-13-2010, 11:07 PM
That worked, thanks guys



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum