Forum Moderators: coopster

Message Too Old, No Replies

elseif not working

         

dkin

9:17 pm on Aug 26, 2005 (gmt 0)

10+ Year Member



i have no idea whats wrong with this code.

I am not getting a value returned no matter what I enter.

Advice?

if ($tba && $day == "")
{
$release = $quarter.'/'.$year2;
}
elseif ($tba && $quarter == "")
{
$release = $month.'/'.$day.'/'.$year;
}
elseif ($day && $quarter == "")
{
$release = $tba;
}

jatar_k

9:19 pm on Aug 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try with a space in between

else if

try also using an else at the end as a catch all

dkin

10:13 pm on Aug 26, 2005 (gmt 0)

10+ Year Member



ok, so this is the updated script.

if ($tba && $day == "")
{
$release = $quarter.'/'.$year2;
}
else if ($tba && $quarter == "")
{
$release = $month.'/'.$day.'/'.$year;
}
else
{
$release = $tba;
}

But still I get nothing

jatar_k

10:21 pm on Aug 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what check are you actually running on $tba? Are you just checking if it is set? If so, why not do it explicitly.

also have you checked all the data you are feeding into it? Without knowing what your test case is it is very difficult to know what should be happening or what is misbehaving.

opiston

6:23 am on Aug 29, 2005 (gmt 0)

10+ Year Member



Hi dkin,
Did you forget to
echo $release;

Opiston

dkin

8:28 am on Aug 29, 2005 (gmt 0)

10+ Year Member



no the working code looks like this

if ($tba == "" && $day == "")
{
$release = $quarter.'/'.$year2;
}
else if ($tba == "" && $quarter == "")
{
$release = $month.'/'.$day.'/'.$year;
}
else
{
$release = $tba;
}

echo $release;

dreamcatcher

10:45 am on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are all your variables populating as they should be? There is a reason that the statement isn`t working, so echo each variable before the statement to compare.

Also, do you have this statement in a function? Should the variables be global?

Just some thoughts.

dc

dkin

3:06 pm on Aug 29, 2005 (gmt 0)

10+ Year Member



everything is working fine, the code that I posted works perfectly for me.