failing elseif construct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bert

    failing elseif construct

    Hi,

    Can anybody see anything wrong with this:

    <-- snip -->
    // some other ifs and elseifs that seem to work okay

    elseif ($CH_address_sa me != 1)
    {
    if ($PayMethod == "credit" && empty($CH_Addre ss1)
    || $PayMethod == "credit" && empty($CH_City)
    || $PayMethod == "credit" && empty($CH_Zip)
    || $PayMethod == "credit" && empty($CH_Count ry))
    {
    $err = 1;
    }
    }

    The CH_address_same variable is being posted to the server using a checkbox
    with a checked value of '1'.

    For some reason if the first clause returns true the second clause chokes?
    I can't see why. But I am a beginner!

    B


  • point

    #2
    Re: failing elseif construct

    Study the example....mayb e it'll get to you.... :)

    just copy-paste and run....

    <?php

    If($_SERVER{'RE QUEST_METHOD'}= ="POST")
    {
    print("<u>These variables are posted:</u><br>\n");
    foreach($_POST as $name=>$value)
    print("Variable <b>$name</b> has value $value.<br>\n") ;
    }

    ?>
    <html>
    <head>
    <title>CheckBox es</title>
    </head>
    <body>
    <form name="testForm" action="<?=$_SE RVER{'PHP_SELF' } ?>" method="POST">
    <input type="checkbox" name="Check_1"> Text_1
    <input type="checkbox" name="Check_2"> Text_2
    <input type="submit" name="submit" value="Submit">
    </body>
    </html>

    hope this help...

    point


    "Bert" <no@spam.com> wrote in message
    news:bhbanp$c9v $1$8300dec7@new s.demon.co.uk.. .[color=blue]
    > Hi,
    >
    > Can anybody see anything wrong with this:
    >
    > <-- snip -->
    > // some other ifs and elseifs that seem to work okay
    >
    > elseif ($CH_address_sa me != 1)
    > {
    > if ($PayMethod == "credit" && empty($CH_Addre ss1)
    > || $PayMethod == "credit" && empty($CH_City)
    > || $PayMethod == "credit" && empty($CH_Zip)
    > || $PayMethod == "credit" && empty($CH_Count ry))
    > {
    > $err = 1;
    > }
    > }
    >
    > The CH_address_same variable is being posted to the server using a[/color]
    checkbox[color=blue]
    > with a checked value of '1'.
    >
    > For some reason if the first clause returns true the second clause chokes?
    > I can't see why. But I am a beginner!
    >
    > B
    >
    >[/color]


    Comment

    • Jeffrey Silverman

      #3
      Re: failing elseif construct

      On Tue, 12 Aug 2003 19:46:02 +0100, Andy Hassall wrote:
      [color=blue]
      ><snip!>
      >
      > Be a bit more specific. 'choke' isn't a Boolean value...
      > <snip!>[/color]

      It could be...

      if ($choke) {
      $cpr->heimlich($vict im);
      }


      --
      Jeffrey D. Silverman | jeffrey AT jhu DOT edu
      Johns Hopkins University | Baltimore, MD
      Website | http://www.wse.jhu.edu/newtnotes/

      Comment

      Working...