paradrenaline Posted February 10, 2007 Share Posted February 10, 2007 I am using PHPMailer and I have having a problem getting a variable($name) to display in my HTML version of the message. The variable is embedded within the code for another variable $Body. $Body =' <html> <head> <title></title> </head> <body> <p>Dear $name,</p> ........more code '; My question is this: how do I make a call to a variable within a variable? Do I need to use double quotes instead of single here as shown in this example? // HTML body $body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>"; Any help would be great, I am just not certain how to call the variable and was unable to find an example. Thanks for your time to help! Link to comment https://forums.phpfreaks.com/topic/37922-solved-php-mail-embedded-variable-call/ Share on other sites More sharing options...
trecool999 Posted February 10, 2007 Share Posted February 10, 2007 I don't know... Try this: // HTML body $body = "Hello <font size=\"4\"><? echo $row["full_name"] ?></font>, <p>"; I doubt it'll work, but it's worth a go. Link to comment https://forums.phpfreaks.com/topic/37922-solved-php-mail-embedded-variable-call/#findComment-181500 Share on other sites More sharing options...
ShogunWarrior Posted February 10, 2007 Share Posted February 10, 2007 1) Just for learning, we don't usually say you "call" variables because you are not making them do anything which you do with functions. 2) What you do is finish the string, insert the variable and then start the string again. For instance: $myString = "The name of my site is" . $sitename . " and etc"; Here is an example with single quotes and multiple variables: $myString2 = 'I am ' . $name .' and I am ' . $feeling . ' to meet you'; Link to comment https://forums.phpfreaks.com/topic/37922-solved-php-mail-embedded-variable-call/#findComment-181502 Share on other sites More sharing options...
compas Posted February 10, 2007 Share Posted February 10, 2007 Hi, php variables within single quotes will act as a constant. please try with doubtle quotes. can you pls clarify me whether you are trying to parse a html mail to take the fill name or you having a standard template for the mail and you are trying to replace the name in that template. Regards, Link to comment https://forums.phpfreaks.com/topic/37922-solved-php-mail-embedded-variable-call/#findComment-181510 Share on other sites More sharing options...
paradrenaline Posted February 10, 2007 Author Share Posted February 10, 2007 I am indeed trying to replace the name in the template. Thanks for the help and the learning about "calling" functions not variables! ShogunWarrior your suggestion worked perfect. I appreciate the help greatly. take care Link to comment https://forums.phpfreaks.com/topic/37922-solved-php-mail-embedded-variable-call/#findComment-181519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.