On Sun, 2005-10-30 at 21:16 -0500, John Taylor-Johnston wrote:
> I need to generate embedded php within in a mysql record. $contents is 
> the actual contents of that record.
> 
> <?php
> $contents = "<div class=\"indent\" style=\"font-size: 16px; font-family: 
> arial,helvetica; font-weight: bold;\">About the Project</div>
> <?php echo \"hello world\"; ?>";
> echo eval($contents);
> ?>
> 
> I get this error:
> Parse error: parse error in /var/www/html2/test.php(4) : eval()'d code 
> on line 1
> 
> If I just echo $contents, my browser spits out:
> 
> <div class="indent" style="font-size: 16px; font-family: 
> arial,helvetica; font-weight: bold;">About the Project</div>
> <?php echo "hello world"; ?>
> 
> What's wrong? eval() is the correct thing to do, I thought?
> 

eval() expects PHP code, not HTML with embedded PHP code. Try this
(untested):

eval( " ?> $contents <?php " );

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to