Jump to content

Variable holding php code....


ActaNonVerba1

Recommended Posts

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

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.

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.