another way of doing it would be to ditch using variables
in the actual text string altogether, and just use place
holders.... use {varname} instead of $varname, and then
you dont need to eval anything... just use a simple
regexp
$fullname = "Roy Rogers";
$data = array(
'name' => 'Johnny',
'webname' => 'jn4523',
'this' => $this,
'fullname' => $fullname,
);
$text = "Dear {name}, your webhosting acccount {webname}
is ready for {fullname}...";
print preg_replace('/{(.*?)}/e', '$data[$1]', $text);
> -----Original Message-----
> From: Kristian Duske [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 26, 2001 7:28 AM
> To: php-general
> Subject: RE: [PHP] sending e-mail with variables
>
>
> > $subject =$row["msub"]; //"Your webhosting account at
> > $hostname.$domain$tld";
> > $message .= $row["mline1"]; //"Dear $fullname,\n";
> >
> > $message .= $row["mline2"];//"Your webhosting account has been
> > created. Please use the\n";
> > $message .= $row["mline3"];//"following data to log in:\n";
> > Now my problem is it does not fill in the variables when it sends the
> > e-mail.The reason I am doing this is the end user of this program
> > what's to be able two
> > change what the e-mail says. How can I do this so it fills the
> > variables in. Or am I going about this totally wrong
>
> If I understand you correctly, you have to eval the code that you get from
> the database. That would be:
>
> $subject = eval($row["msub"]);
>
> This interpretes the string that is stored in $row["msub"] as php code and
> assings the result of the interpretation to $subject. Make sure that you
> have assigned all variables that you use in $row["msub"] before you eval it.
>
> Kristian
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]