emexinc Posted August 13, 2006 Share Posted August 13, 2006 ...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... Quote Link to comment Share on other sites More sharing options...
fenway Posted August 13, 2006 Share Posted August 13, 2006 "exact code"? "*.* php file"? Quote Link to comment Share on other sites More sharing options...
emexinc Posted August 13, 2006 Author Share Posted August 13, 2006 exact code = $variable*.*.php = variable_page.php...the code is a bunch of lyrics...and there would be php variables mixed into that...so that the user can select what key the song would be shown in...thanks for your help Quote Link to comment Share on other sites More sharing options...
fenway Posted August 14, 2006 Share Posted August 14, 2006 I'm quite confused. Quote Link to comment Share on other sites More sharing options...
emexinc Posted August 14, 2006 Author Share Posted August 14, 2006 ...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> A Bm D G D 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> <?php $_1.' '.$_2 ?>...when i retrieve this...<?php $_1.' '.$_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... Quote Link to comment Share on other sites More sharing options...
fenway Posted August 14, 2006 Share Posted August 14, 2006 Unfortunately, it doesn't -- at least not to me. You have it working in one case, but now you're trying to use different variables? Quote Link to comment Share on other sites More sharing options...
emexinc Posted August 15, 2006 Author Share Posted August 15, 2006 ...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... Quote Link to comment Share on other sites More sharing options...
fenway Posted August 15, 2006 Share Posted August 15, 2006 Oh... you want to eval() the string that comes back. That sounds horribly insecure. Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 15, 2006 Share Posted August 15, 2006 You are unlucky, becauseYour 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 Quote Link to comment Share on other sites More sharing options...
emexinc Posted August 16, 2006 Author Share Posted August 16, 2006 ...answer found...thanks guys...simplest fix...i just replacedecho $row['lyrics_and_chords']...with... eval('?>' . $row['lyrics_and_chords'] . '<?php ');...when i retrieve items from my database...thanks for your time... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.