FinalFrontier Posted December 15, 2011 Share Posted December 15, 2011 Does anyone know why this isn't working? $body = " Dear ".if ($row['customertitle'] != '') {echo $row['customertitle'].' '.$row['customerlastname'];} else (echo $row['customerfirstname'];}." <BR> This is a test. ".$_SERVER['SERVER_ADDR']." <BR> ".echo $accessinformation." "; Link to comment https://forums.phpfreaks.com/topic/253215-15-seconds-of-thought-and-i-dont-know-what-to-call-the-subject-sorry/ Share on other sites More sharing options...
kicken Posted December 15, 2011 Share Posted December 15, 2011 Because you can't embed an if condition into a string like that, and you don't echo vars into a string. Move your condition outside and set a variable, then embed that variable in the string. As for your echo, just concatenate the variable. if ($row['customertitle'] != '') { $name = $row['customertitle'].' '.$row['customerlastname']; } else ( $name = $row['customerfirstname']; } $body = " Dear ".$name." <BR> This is a test. ".$_SERVER['SERVER_ADDR']." <BR> ".$accessinformation." "; Link to comment https://forums.phpfreaks.com/topic/253215-15-seconds-of-thought-and-i-dont-know-what-to-call-the-subject-sorry/#findComment-1298070 Share on other sites More sharing options...
FinalFrontier Posted December 15, 2011 Author Share Posted December 15, 2011 Ahhhh. That idea came accross my mind before! Why didn't I try it!! dumb! Thanks dude! Link to comment https://forums.phpfreaks.com/topic/253215-15-seconds-of-thought-and-i-dont-know-what-to-call-the-subject-sorry/#findComment-1298072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.