Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.