On Tue, 23 Apr 2002, Jennifer Downey wrote:
I am wondering. When you use an if else statement and a condition exists
isn't the if part suppose to stop?
Then if the condition doesn't exist it is suppose to do something else?
I am wondering because I have a form that goes something like this.
If and else expect to be followed by exactly 1 statement. To aggregate
multiple statements as one, surround them with {curly braces}. I'm
guessing you didn't do that, and you're seeing the execution of all but
the first of the statements following the else.
So it should be:
if ($var1)
Does it show the message and the form or just the message?
-Natalie
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 12:23 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
If and else expect to be followed by exactly 1
Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 12:23 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
If and else expect to be followed by exactly 1 statement. To aggregate
multiple statements as one, surround them with {curly braces}. I'm
guessing yo
you could look into if no one else has any better ideas :-)
-Natalie
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 12:26 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
It shows both.
Natalie Leotta [EMAIL PROTECTED] wrote
xpertise, but it's
something you could look into if no one else has any better ideas :-)
-Natalie
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 12:26 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
It shows both.
Natali
Is this a nested if? (inside another if statement?)
- Original Message -
From: Jennifer Downey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 1:05 PM
Subject: Re: [PHP] If else question
I just looked at my hosting service thinkg it may have been because
01c1eae9$d58f4360$[EMAIL PROTECTED]...
Is this a nested if? (inside another if statement?)
- Original Message -
From: Jennifer Downey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 1:05 PM
Subject: Re: [PHP] If else question
I just looked at my hosting servic
your mind...
- Original Message -
From: Jennifer Downey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 12:17 PM
Subject: Re: [PHP] If else question
No this is the first if statement but there are nested if's after that.
I'd post the code but everyone yells at me about
]]
Sent: Tuesday, April 23, 2002 7:18 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
No this is the first if statement but there are nested if's after that.
I'd post the code but everyone yells at me about my coding style. If you
promise not to yell I will post it.
Jennifer
-Bd
]
Subject: Re: [PHP] If else question
No this is the first if statement but there are nested if's after that. I'd
post the code but everyone yells at me about my coding style.
If you promise not to yell I will post it.
Jennifer
-Bd- [EMAIL PROTECTED] wrote in message
001d01c1eae9$d58f4360$[EMAIL
Ok you asked for it.
Don't say I didn't warn you.
session_start();
$query = SELECT name FROM {$config[prefix]}_users WHERE
uid={$session[uid]};
$ret = mysql_query($query);
while($row = mysql_fetch_array($ret))
{
$user = $row['name'];
$query = SELECT uid, id, iname, image, quantity, type FROM
www.PHPBeginner.com // where PHP Begins
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 7:48 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
Ok you asked for it.
Don't say I didn't warn you.
session_start();
$query
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
Ok you asked for it.
Don't say I didn't warn you.
session_start();
$query = SELECT name FROM {$config[prefix]}_users WHERE
uid={$session[uid]}; $ret = mysql_query($query); while($row =
mysql_fetch_array($ret)) {
$user = $row['name
you've got something wrong in your code.
Sincerely,
Maxim Maletsky
Founder, Chief Developer
www.PHPBeginner.com // where PHP Begins
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 7:48 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP
fetched via mysql_fetch_array()
to ensure they contain valid data?
- Original Message -
From: Jennifer Downey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 12:48 PM
Subject: Re: [PHP] If else question
Ok you asked for it.
Don't say I didn't warn you.
session_start
]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 12:48 PM
Subject: Re: [PHP] If else question
Ok you asked for it.
Don't say I didn't warn you.
session_start();
$query = SELECT name FROM {$config[prefix]}_users WHERE
uid={$session[uid]};
$ret = mysql_query($query);
while($row
Jennifer, satus!
People are nervous here!
Sincerely,
Maxim Maletsky
Founder, Chief Developer
www.PHPBeginner.com // where PHP Begins
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 7:48 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP
rd, have you printed out all the values fetched via
mysql_fetch_array()
to ensure they contain valid data?
- Original Message -
From: Jennifer Downey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 12:48 PM
Subject: Re: [PHP] If else question
Ok y
eveloper
www.PHPBeginner.com // where PHP Begins
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 7:48 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
Ok you asked for it.
Don't say I didn't warn you.
session_start();
Aeh, sorry - but is the 1 you test for actual a number or is it a string?
I had made this mistakes earlier, so also try
if ( $quantity == 1)
Maybe I´m absolutely wrong, (PHP 3 knowledge) but
Oliver
At 23.04.2002 10:48, you wrote:
Ok you asked for it.
Don't say I didn't warn you.
incerely,
Maxim Maletsky
Founder, Chief Developer
www.PHPBeginner.com // where PHP Begins
-Original Message-
From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 7:48 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] If else question
Ok y
Message -
From: Jennifer Downey [EMAIL PROTECTED]
Date: Tuesday, April 23, 2002 10:26 am
Subject: Re: [PHP] If else question
Ok I have hard coded $quantity so it does = 0 and else still prints.
Maxim Maletsky ) [EMAIL PROTECTED] wrote in message
004701c1eaf1$c915c6b0$92e3021a@machine52"
I have it. I actually got it!
I had the if statement in the wrong place.
Here is what I did:
if($quantity 1)
{
echo Sorry I can't seem to locate this item;
}
else
{
//check if form has been submitted
if($submit)
{
}
else
{
//if the form has not been submitted run the following
echo FORM
Of course it's legal, absolutely.
You have to make sure though that you
don't use double quotes in php portion,
and if you do, you have to escape them
for instance:
echo font color=\red\;
if you paste the code that's causing the
problem, we can take a look.
Vlad
-Original Message-
On Thu, 14 Mar 2002, Brad Harriger wrote:
!-- snip --
?
// Now back to the PHP code
$d = 250;
}
else {
$e = Does not apply.
}
?
I have some code similar to this example. When I run the code in my
browser, I get a parse error on the last line (?).
Replace:
$e = Does not
26 matches
Mail list logo