PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
insanomania911
Forum Newbie
Posts: 1 Joined: Thu Apr 03, 2008 5:29 pm
Post
by insanomania911 » Thu Apr 03, 2008 5:32 pm
Greetings,
I don't understand why this VERY simple code doesn't seem to work in PHP:
***** PLEASE USE THE CODE TAG WHEN POSTING *****
Code: Select all
if ($num == '1')
{
if($check == 'order')
{
echo "this is order";
}
else
{
echo "this is payment";
}
}
I echo $num it is 1 so it goes in the loop and I echo $check it is order but somehow it skips that if statements and the final output will be "this is payment"
Does anybody knows why ?
Thanks,
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Thu Apr 03, 2008 6:49 pm
Are you sure $check is exactly 'order' and not something like ' order ' ?
(#10850)
it2051229
Forum Contributor
Posts: 312 Joined: Tue Dec 25, 2007 8:34 pm
Post
by it2051229 » Thu Apr 03, 2008 6:51 pm
uhhuuuhhhh where did you echo $check? which part of the code?
Beauford
Forum Newbie
Posts: 3 Joined: Thu Apr 03, 2008 9:19 pm
Post
by Beauford » Thu Apr 03, 2008 9:41 pm
Works for me. Check your variables to make sure they are getting the right values.
Code: Select all
$num = 1;
$check = "order";
if ($num == '1')
{
if($check == 'order') {
echo "this is order";
}
else {
echo "this is payment";
}
}
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Fri Apr 04, 2008 3:07 am
sajithmr
Forum Newbie
Posts: 1 Joined: Fri Apr 04, 2008 4:43 am
Location: India
Contact:
Post
by sajithmr » Fri Apr 04, 2008 4:48 am
Check some things:
1) == is there ? or instead of whether u put a single '=' symbol.
2) for comparing values with type use '===' instead of '=='