Jump to content


Photo

IF inside IF


  • Please log in to reply
2 replies to this topic

#1 lurah

lurah
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 September 2006 - 12:14 AM

Hi all.
I have tried to search answer but havent got this solved.
write.php receives $_POST values from another file. Values are passed as should. I tested many times with echo $value.

if (($cat != "new")  && ($newcat != ""))
                   {  
                           echo "Select \"New category\" to create it.<br>";
                           $false++;
                    }

if ($cat_new != "")
          {
                   if ($cat != "new")
                   {  
                           echo "Select \"New category\" to create it.<br>";
                           $false++;
                    }
           }

Both ways, i allways end up on $false++ even the values are right.
So the idea is, that if $cat_new != "", then $cat must be "new" or $false increases.

#2 DarkHavn

DarkHavn
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 18 September 2006 - 12:17 AM

Well there a couple of options you can go

if(){
elseif() {

}

}

or in this case i would go with switch statements


switch($_POST){
case $cat != "new":
echo "yep"
breal;
case empty($cat):
echo "empty";
break;

}

in a rush so search google.com for php switch statement tutorial

#3 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 September 2006 - 12:32 AM

Are you checking if register globals is on??

Maybe you need...
<?php

if (($_POST['cat'] != "new")  && ($_POST['newcat'] != ""))
                   {  
                           echo "Select \"New category\" to create it.<br>";
                           $false++;
                    }
?>

follow me on twitter @PHPsycho




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users