Hi, I'm learning MySQL databases and tables...I have a problem and need someone to please help me figure this out... Here's the situation: I have a webpage which is a template based site. I want to add text in table like this: <h1>{$sitename} Privacy Policy </h1> </div> </div> <div> <div align="justify"><br /> This privacy policy covers how we treat personal information that we collect and receive. We do not intend to collect any personal information from children under 13 unless we believe such collection to be permitted by law. Please see below for our policy with respect to children under 13. <br /> PHP: when I enter this and create a table and call the page, I do not see {$sitename}...is there's a function I need to use so the page shows the site name when reading data from mysql table? Thanks for your help!
the php code you retrieved will be treated as a string and will never be parsed. If you would like it to be parsed as php, try... // $string is the code that was returned from the mysql db eval("echo '".$string."'"); PHP: WARNING: eval can be a serious security hole if you do not control what goes into your database. If this is for user-generated content, I would suggest using some type of template parser over this.
nQQb, you need to assign the value of {$sitename} to your template engine. Check out the documentation for the templating system that you use. For Smarty, for example, it would be something like: $smarty = new Smarty(); $smarty->assign("sitename", "My Site"); $smarty->display("yourTplFile.tpl"); PHP: