Jump to content

echo HTML, eval PHP?


br3nn4n

Recommended Posts

I have some stuff in a database:

 

<h1>Users</h1>
<p>
<?php $q = mysql_query("....");
          $qa = mysql_fetch_assoc($q);
          ....more php....
?>
</p>

 

Here's my problem: If I

eval()

it all, it gives my a parse error about the "<" in the <h1> tag. Makes sense. The fix is to manually echo out any HTML, but that involves having to...yep, manually echo it all. :)

 

I'm thinking I can have it do the following:

1. Find the HTML portions and stick them in an echo, and addslashes().

2. Find the stuff inside the <?php and ?> and place it inside an eval().

 

I'm not sure if I'm just missing something or if there really is no easier way to mix some html and PHP...? Would this be the way you'd do it?

 

If you have any idea I'm more than open to suggestions at this point!!  :)

Link to comment
https://forums.phpfreaks.com/topic/169445-echo-html-eval-php/
Share on other sites

eval('?>' . $string);

 

Alright....I apologize but where would I place that / how would I use it? I'll try to see if I can figure it our with my scripts but I'm thinking that you're implying I can leave my database entry as I have it posted above and just use that eval string?

 

Thanks for your quick response!!

Link to comment
https://forums.phpfreaks.com/topic/169445-echo-html-eval-php/#findComment-894043
Share on other sites

Uhm... $string would be a variable containing the code, so in your case, $string would contain:

 

<h1>Users</h1>
<p>
<?php $q = mysql_query("....");
          $qa = mysql_fetch_assoc($q);
          ....more php....
?>
</p>

 

I.e., the stuff from your database.

Link to comment
https://forums.phpfreaks.com/topic/169445-echo-html-eval-php/#findComment-894048
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.