@zackbloomFeb 17.2007 — #I'm not sure what the problem is. The solution I wrote about is actually what php.net is talking about when it suggests using output control functions.
@papa_faceauthorFeb 17.2007 — #Well I did direct you to the thread to save me doing this. But basically I have a peice of HTML coding in a database. It looks like this at the moment: <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Please activate your membership </td> </tr> <tr> <td><a href="http://some.com/activate.php?k=<?php $randomnumber ?>&&u=<?php $username_gen?>">Click on this link to activate your membership </a></td> </tr> <tr> <td>or copy and paste this link to your browser: http://some.com/activate.php?k=<?php $randomnumber ?>&&u=<?php $username_gen ?></td> </tr> </table> I am trying to get it to process the variables in the HTML code/PHP so in my script it will run and send an email out: $username_gen = base64_encode($username); $emailselect = mysql_query("select content_content from content where content_name='email_activation_content'"); $emailfrom = mysql_query("select content_content from content where content_name='email_activation_from'"); $emailsubject = mysql_query("select content_content from content where content_name='email_activation_subject'");
@zackbloomFeb 17.2007 — #Ahhhhh. eval attempts to evaluate all the text you give it as php code, regardless of the <?php tags. I recommend you use string replacement. You have in your database the following:
[code=html] <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Please activate your membership </td> </tr> <tr> <td><a href="http://some.com/activate.php?k=[{[RANDOM_NUMBER]}]&u=[{[USERNAME]}]">Click on this link to activate your membership </a></td> </tr> <tr> <td>or copy and paste this link to your browser: http://some.com/activate.php?k=[{[RANDOM_NUMBER]}]u=[{[USERNAME]}]</td> </tr> </table> [/code]
Then run the following:
<<<get the text from the database and store it as $file>>> [code=php] $file = str_replace(array('[{[RANDOM_NUMBER]}]','[{[USERNAME]}]'),array($randomnumber,$username),$file); [/code] If you need it to be more extensible you could use regular expressions to replace the strings with vars.
@bokehFeb 17.2007 — #Ahhhhh. eval attempts to evaluate all the text you give it as php code[/QUOTE]eval() could be used on that string just to expand the variables.[code=php]<?php
$randomnumber = '12345'; $username_gen = 'bokeh';
$From_DB = ' <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Please activate your membership </td> </tr> <tr> <td><a href="http://some.com/activate.php?k={$randomnumber}&u={$username_gen}">Click on this link to activate your membership </a></td> </tr> <tr> <td>or copy and paste this link to your browser: http://some.com/activate.php?k={$randomnumber}&u={$username_gen}</td> </tr> </table> ';