danweav Posted June 19, 2010 Share Posted June 19, 2010 I'm simply trying to write some script that says... If A = B then $cbhop = C else $cbhop = D. Then print $cbhop. This is the code I've created so far... but for some reason its just not quite right yet... I'm currently getting a 'unexpected T_ECHO' error. Any ideas on how to get this to work? <?php if ($row_RS_UserDetails['User_cbaff'] == 'NA') { $cbhop = echo $row_RS_ReferralDetails['User_ClickBank']; } else { $cbhop = echo $row_RS_UserDetails['User_cbaff']; } ?> <?php echo $cbhop; ?> Regards, Dan Link to comment https://forums.phpfreaks.com/topic/205253-simple-echo-code/ Share on other sites More sharing options...
bobby317 Posted June 19, 2010 Share Posted June 19, 2010 <?php if (a == b) { $cbhop = C; } else { $cbhop = D; } print $cbhop; ?> I belive this is what you are trying to do. Link to comment https://forums.phpfreaks.com/topic/205253-simple-echo-code/#findComment-1074364 Share on other sites More sharing options...
ChrisA Posted June 19, 2010 Share Posted June 19, 2010 Dan - You don't want the 'echo's inside your if/else statement, it should be: <?php if ($row_RS_UserDetails['User_cbaff'] == 'NA') { $cbhop = $row_RS_ReferralDetails['User_ClickBank']; } else { $cbhop = $row_RS_UserDetails['User_cbaff']; } ?> <?php echo $cbhop; ?> Link to comment https://forums.phpfreaks.com/topic/205253-simple-echo-code/#findComment-1074366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.