if else stament not working

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

Post Reply
toasty525
Forum Newbie
Posts: 10
Joined: Wed Apr 05, 2006 12:48 pm

if else stament not working

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

What does this line supposed to do?

Code: Select all

=$wc[$i['child']];
(#10850)
toasty525
Forum Newbie
Posts: 10
Joined: Wed Apr 05, 2006 12:48 pm

Post 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";} 
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Moving that return character did the trick huh ... I'll have to start using that trick in my debugging! 8O
(#10850)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply