Really Easy Newbie Question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Guys,

This is probably really simple, but for the life of me I can't figure it

It might be a MYSQL issue, so I apologise right now if that is the case.

Basically I'm writing a script which will send an automated email to a
given email address. No problems so far, however I would like the email
message to be taken from a MYSQL database so that the website
administrator can change the text acordingly. Again, no problem.


I would like it so that the Email contains information pertinent to the
recepient, for example.

Dear $EmailRecepientName,

Your booking for $BookingDate has been confirmed
and your depoist of $DepositPrice is due on

Is there anyway I can enter this into a MYSQL field and have PHP render
it correctly ?

Thanks in advance for any help..

Re: Really Easy Newbie Question

Carved in mystic runes upon the very living rock, the last words of
Graham Wakley of comp.lang.php make plain:

Quoted text here. Click to load it

Try the hl_VarSub function from HoloLib:

Alan Little
Phorm PHP Form Processor /

Re: Really Easy Newbie Question

This should be fairly straight forward. Perhaps seach the database by email
address (SELECT * FROM table WHERE email= '$emailAddress')

Then use the returned variables. You may have problems is someone with the
same mail address has several entries in that database perhaps use ORDER by
$date for the most recent record (assuming you have a date entry in your

Quoted text here. Click to load it

Re: Really Easy Newbie Question

Graham Wakley contained the following:

Quoted text here. Click to load it

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: Really Easy Newbie Question

 .oO(Geoff Berrow)

Quoted text here. Click to load it

eval() is slow. Other options:

* sprintf() and %s placeholders in the text
* str_replace() and template-like things in the text
  (, , ...)


Re: Really Easy Newbie Question

Sorry if I am late on this, but yes.  str_replace() is the easiest and
best way to go about doing this.  Put the following in your sql

Dear User, I think you and {friends name} are both really great guys.
Be sure to tell that he has work tomorrow.  Bye.

str_replace("User", $UserName, $Message);

str_replace("replace this text", "with this text", $in_this_string);

and so on.  If you would like more info on using the string replace
function here is the documentation.

Site Timeline