printing mysql template field variable prints as string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cribs
Forum Newbie
Posts: 3
Joined: Fri Sep 02, 2005 2:44 pm

printing mysql template field variable prints as string

Post by cribs »

I am inserting content into a mysql table. When I read the table and print the variable it prints as a string.
example: print $header; will echo <title><?php echo $title; ?></tilte>
$title = 'My New Page';
I want the print $header tag to print <title>My New Page</table>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll have to research eval(). Do note that usage of eval() can be and is quite dangerous. You may want to change the way you're inserting the text so it's not code, but replacable data such as the following:

Code: Select all

<title>{{title}}</tilte>
You can then use simple string replacement or regular expressions to translate {{title}} to $title.
Post Reply