Jump to content

PHP code within mysql database content


emexinc

Recommended Posts

...is it possible to put php code ( such as a variable ) into a mysql database ( i know this is a yes )...and then be able to pull out that exact code from the database ( i can't get this to work ) and then implement it into a *.*.php file...and then have it conform to whatever that desired variable should be?...i really hope this makes sense as to what i would like to do...thanks for your time...
Link to comment
Share on other sites

...sorry...let me explain this...
...i have a database with 3 columns...( TITLE - AUTHOR - LYRICS_AND_CHORDS )...
* EXAMPLE *...my first row has the following information...
...under TITLE - Beautiful Day
...under AUTHOR - U2
...under LYRICS_AND_CHORDS - <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A Bm D G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; A <br>The heart is a bloom, shoots up through the stony ground.</p>

...now if i put all this and then retrieve all these details and input them into variables on a php page, then everything works...but...if i do the following...

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php $_1.'&nbsp;'.$_2 ?>

...when i retrieve this...<?php $_1.'&nbsp;'.$_2 ?> is written exactly as i had put it in...whereas $_1 and $_2 should of been replaced by given variables and then those variables should of been displayed...

...please tell me this makes some sense...
Link to comment
Share on other sites

...i'm making this way too confusing...here it is...i can input php code into a database...such as <?php echo $_1 ?> ...but when I retreive that from the database...it shows up exactly as <?php echo $_1 ?> ...whereas it should of echoed the variable $_1 ( whatever that may be ) ...and that should show up in the source code of that page...but all i see in the source code is <?php echo $_1 ?> ...thanks for continuing to help me with this...
Link to comment
Share on other sites

You are unlucky, because
Your code must not have <? ?> <?php ?>
only php code like
[code]
$code="echo('Hello');";
eval($code); // Hello
[/code]

So you have to use echo for all html and for php use it like you would without the tags and use eval
Link to comment
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.