ActaNonVerba1 Posted February 11, 2011 Share Posted February 11, 2011 Hey guys im making a PHP page using PHP So i have this ##################################################### # Make the PHP page # ##################################################### $PHPCode = " <?php //Title of page used to select the correct record from the database $Title = '".$Name."'; //Use the database information stored in this file include ($_SERVER['DOCUMENT_ROOT'].'/MySQL/Lighthouses-Database-Connection-Information.php'); //Take the information from the database using the method in this file include ($_SERVER['DOCUMENT_ROOT'].'/MySQL/Retrieve-Information.php'); //Process the information using the methods in this file include ($_SERVER['DOCUMENT_ROOT'].'/MySQL/Processing.php'); //Use the layout HTML held in this file include ($_SERVER['DOCUMENT_ROOT'].'/MySQL/PageCode-Lighthouse-Information-Page.php'); //Display the page code made. Resulting in the page displayed. echo $pagecode; ?> "; However, i keep getting syntax errors, possibly due to the fullstops. How shall i get round this?! Danny Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/ Share on other sites More sharing options...
BlueSkyIS Posted February 11, 2011 Share Posted February 11, 2011 post the error so we know what it is. Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1172821 Share on other sites More sharing options...
Jessica Posted February 11, 2011 Share Posted February 11, 2011 You're trying to set a variable that doesn't exist inside a string. Set your variables, then include all the files. Don't try to put your code in a string and echo it.... Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1172822 Share on other sites More sharing options...
kenrbnsn Posted February 11, 2011 Share Posted February 11, 2011 What is the exact error you're getting? Ken Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1172824 Share on other sites More sharing options...
gizmola Posted February 11, 2011 Share Posted February 11, 2011 Well let's get down to it... if you want to actually do something with that code other than display it, you're going to need to use eval(). With that said, eval() is one of the most dangerous functions in the language from an exploit vector -- right up there with the url wrappers built into include(). Any mistake that allows people to inject their own code, and you've given the the power to do anything that apache can do on your server. Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1172834 Share on other sites More sharing options...
ActaNonVerba1 Posted February 11, 2011 Author Share Posted February 11, 2011 Its just PHP code i want to fwrite into a file. Im just getting Syntax errors in DW, but havnt uploaded it yet... Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1173018 Share on other sites More sharing options...
trq Posted February 11, 2011 Share Posted February 11, 2011 Its just PHP code i want to fwrite into a file. Why would you want to do this? Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1173031 Share on other sites More sharing options...
ActaNonVerba1 Posted February 11, 2011 Author Share Posted February 11, 2011 This script makes other PHP pages and this is the basic source code of the page that is being created. The only difference on each page is the $Name in the $Title var. So yes i need $PHPCode to hold this data. But for some reason, i cannot work out how to use quotes to get it to work, and i can seem to escape the . [full stop] and i think this is causing syntax errors.... Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1173034 Share on other sites More sharing options...
trq Posted February 12, 2011 Share Posted February 12, 2011 This script makes other PHP pages Again, why would you want/need to do this? Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1173050 Share on other sites More sharing options...
ActaNonVerba1 Posted February 12, 2011 Author Share Posted February 12, 2011 Doesn't matter now Decided to use a file with the PHP as plain text and then use ob_contents. Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1173327 Share on other sites More sharing options...
gizmola Posted February 12, 2011 Share Posted February 12, 2011 FWIW, part of your problem is that you were using double quotes. When you use double quotes for a string, you're telling PHP to interpolate (do variable replacement" of any php variables. To not make that happen, you would have to use single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/227381-variable-holding-php-code/#findComment-1173374 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.