Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

value not getting passed thru eval()

Status
Not open for further replies.

spookie

Programmer
Joined
May 30, 2001
Messages
655
Location
IN
Hi,

I am using this code,
Code:
eval($_SESSION["product"]->GetTemplate($_GET["ID"]));

but the value is not getting passed to the called function.
The value of $_GET["ID"] is set.

Thanks in advance



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
for an eval statement to work, you must pass an argument that resolves into a string with complete php syntax. so your code might look more like this:

Code:
eval("$_SESSION['product']->GetTemplate($_GET['ID']);");

i dont know if this will work, but do take note of the added semicolon at the end of the line of code, as well as the added quote marks so that it is a string.

if that does not work, you can try something like this:

Code:
$s_product = $_SESSION['product'];
$get_template = "GetTemplate(" . $_GET['ID'] . ")";

eval($s_product . "->" . $get_template . ";");

this method uses explicit string concatenation, and builds the actual string content outside of the function call.

if you read the eval() section of the php manual at then i think you would find your answer.
 
miahmiah900
I tried both the ways but both are giving me parse errors.

Thes second one gives me:
parse error, unexpected T_OBJECT_OPERATOR in filename...

Just couldnt getting it worked.
May be the effect of weekend coming up :)

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
What is it that you are trying to do? Does the
Code:
GetTemplate
function return a string to be
Code:
eval
'ed?

//Daniel
 
GetTemplate calls another function .
The functions are as follows,

Code:
function GetTemplate($id)
  {
	  $this->Template = new template ; 	  
	  return $this->Template->GetFrameSet1($id);	   
  }

  function GetFrameSet1($id)
  {
	
    if(!isset($this->FrameSet))
    {
	  $db = new DB;
	 
	
	 $sql = "select frameset from eb_template where template_id = $id";   	 
	     
      $db->query($sql);
      $db->next_record();
      $this->FrameSet = $db->f("frameset");
    }    
    return $this->FrameSet;
  }

Any ideas ?

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
You are using too many functions that I don't know what they return for me to figure out what
Code:
GetTemplate
returns. If you print the return, does it print PHP statements?

//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top