You are here: Re: php/html code stored in mysql « All PHP « IT news, forums, messages
Re: php/html code stored in mysql

Posted by <a> on 03/06/06 07:03

"J.O. Aho" <user@example.net> wrote in message
news:471robFde4e0U1@individual.net...
>a wrote:
>> I've been storing some html data in a mysql database and creating
>> webpages based on that code using a simple "echo $html" type command. I
>> have some php code sprinked in and noticed that php doesn't execute this
>> code, it just prints it. After reading some more about it, i found out
>> you have to use eval() to execute a string of php code. My problem is
>> that there is html/php code. is there a way to "execute" the html code
>> along /w the php code, or somehow seperate it, so only php code gets the
>> eval() function?
>
> Yes you can, there is two ways
>
> --- code 1 ---
> <?PHP
> $code="echo \"test\n\"; ?> <h1>hello</h1> <?PHP echo \"test2\n\"; ";
>
> eval($code);
>
> ?>
> --- eof ---
>
>
> --- code 2---
> <?PHP
> $code="echo \"test\n\"; echo \"<h1>hello</h1>\"; echo \"test2\n\"; ";
>
> eval($code);
>
> ?>
> --- eof ---
>

Cool this seems to be working. I added a few lines to decide if the stored
code starts w/ php or html. I add a '?>' to the beginning of html code to
turn off the php and the same at the end. Seems to be working with html
only code!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация