Jump to content

Pulling Variables From Mysql and Echoing them in PHP


jj20051

Recommended Posts

Ok so I want to send an email with data I pull from MYSQL using PHP. The data contains variables that I want to be part of the email...

 

Example Email Title:

Invoice #{$invoice_id) Is Overdue

$invoice_id is defined in the PHP code and the email title above is stored in mysql. The problem is it won't echo the variable in the email, but chooses to go with an exact display of the title IE like googling something with "" around it...

 

How do I make it so that when I pull a title from MYSQL it fills in any variables {$variable} with what php has stored?

Link to comment
Share on other sites

This idea wreaks of poor design and is precisely the opposite way around to how things should be done.

 

You should be storing the value of your invoice_id within your database and then simply replacing the #{$invoice_id) text within your template with that value.

 

If you still wish to go down the path you are on, take a look at eval, generally though, if you need to use eval your design is incorrect.

Link to comment
Share on other sites

This is an automated emailer that sends out invoices. I want to store the email in the database so that the admin can edit it as if it were a template for the email. I may be doing something wrong, but then again I haven't developed the admin section yet. I might need to just store them in .tpl files, but I'd rather not LOL

Link to comment
Share on other sites

I am not so sure but I guess you can use the str_replace on this. Here is the step

 

1. Pull the data from the database.

2. Use str_replace command to replace the #{$invoice_id) with the right invoice number before sending.

 

I hope that will help. If it makes more confusing, sorry but I need to see your code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.