Page 1 of 1

if else stament not working

Posted: Wed Apr 05, 2006 12:51 pm
by toasty525
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Can someone please tell me why this if else statment isnt working?

Code: Select all

<?if(!empty($i['child'])) {
  =$wc[$i['child']];
} 
else { echo "unspecified"; } ?>


Thanks,
mark.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Apr 05, 2006 12:54 pm
by feyd
What's the orphaned equal sign supposed to do? If you're assuming it will echo, it won't in this instance. Use echo.

Posted: Wed Apr 05, 2006 12:54 pm
by Christopher
What does this line supposed to do?

Code: Select all

=$wc[$i['child']];

Posted: Wed Apr 05, 2006 3:28 pm
by toasty525
Just so you know i solved my problem.
Please see the correct code below.

OLD CODE :

Code: Select all

<?if(!empty($i['child'])) {
  =$wc[$i['child']];
} 
else { echo "unspecified"; } ?>
NEW CODE:

Code: Select all

<?if(!empty($i['child'])) {      
   =$wg[$i['child']]
} else {
   echo "unspecified";} 
?>

Posted: Wed Apr 05, 2006 3:32 pm
by Christopher
Moving that return character did the trick huh ... I'll have to start using that trick in my debugging! 8O

Posted: Wed Apr 05, 2006 3:34 pm
by RobertGonzalez
toasty525 wrote:Just so you know i solved my problem.
Please see the correct code below.

OLD CODE :

Code: Select all

<?if(!empty($i['child'])) {
  =$wc[$i['child']];
} 
else { echo "unspecified"; } ?>
NEW CODE:

Code: Select all

<?if(!empty($i['child'])) {      
   =$wg[$i['child']]
} else {
   echo "unspecified";} 
?>
Question 1: Was is the '=' supposed to be doing here?
Question 2: The array name change is your solution? Just want to be sure.

Suggestion: Using complete opening PHP tags (<?php) instead of short tags.