We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Save return value from en embed to a php variable

Development and Programming

w84me's avatar
w84me
95 posts
14 years ago
w84me's avatar w84me

Hello,

Is it possible to do this

<?php $amount = '{embed="control_panel/home_price" primary="true"}'; ?>

in a template with PHP set to output?

When I echo the $amount I get the correct result but if I try to:

<?php
echo $amount; //here it echoes the price

$sql = "INSERT INTO shop_validation (date_entered,merchant_ref,merchant_id,amount,currency_code) VALUES(UNIX_TIMESTAMP(now()),'$mref','2388',$amount,'0978')";
$query = $this->EE->db->query($sql);
?>

The $amount is replaced with the embed tag

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '="control_panel/home_price" primary="true"},'0978')' at line 1

INSERT INTO shop_validation (date_entered,merchant_ref,merchant_id,amount,currency_code) VALUES(UNIX_TIMESTAMP(now()),'1160_1322916759','2388',{embed="control_panel/home_price" primary="true"},'0978')

What am I doing wrong? Is it the parse order? Are there any alternatives?

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

Depending on what is inside that embed I would create a custom plugin and put all of your code in there.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.