failing elseif construct

This is a discussion on failing elseif construct within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, Can anybody see anything wrong with this: <-- snip --> // some other ifs and elseifs that seem to work ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-12-2003
Bert
 
Posts: n/a
Default 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_same != 1)
{
if ($PayMethod == "credit" && empty($CH_Address1)
|| $PayMethod == "credit" && empty($CH_City)
|| $PayMethod == "credit" && empty($CH_Zip)
|| $PayMethod == "credit" && empty($CH_Country))
{
$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


Reply With Quote
  #2 (permalink)  
Old 08-12-2003
point
 
Posts: n/a
Default Re: failing elseif construct

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

just copy-paste and run....

<?php

If($_SERVER{'REQUEST_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>CheckBoxes</title>
</head>
<body>
<form name="testForm" action="<?=$_SERVER{'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@news.demon.co.uk...
> Hi,
>
> Can anybody see anything wrong with this:
>
> <-- snip -->
> // some other ifs and elseifs that seem to work okay
>
> elseif ($CH_address_same != 1)
> {
> if ($PayMethod == "credit" && empty($CH_Address1)
> || $PayMethod == "credit" && empty($CH_City)
> || $PayMethod == "credit" && empty($CH_Zip)
> || $PayMethod == "credit" && empty($CH_Country))
> {
> $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
>
>



Reply With Quote
  #3 (permalink)  
Old 08-12-2003
Jeffrey Silverman
 
Posts: n/a
Default Re: failing elseif construct

On Tue, 12 Aug 2003 19:46:02 +0100, Andy Hassall wrote:

><snip!>
>
> Be a bit more specific. 'choke' isn't a Boolean value...
> <snip!>


It could be...

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


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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0