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

Issue with EXP:QUERY using a PHP variable

Development and Programming

lcallif's avatar
lcallif
25 posts
14 years ago
lcallif's avatar lcallif

The following is the code that I am using, or trying to use:

<?php $mem_id = $this->EE->session->userdata(‘member_id’); $tabname = $this->EE->db->dbprefix . “Advertisement”; $Sql = “SELECT Advert, Desc, PDF, StartDt, EndDt From ” . $tabname . ” Where 1=1 and MemberID = ” . $mem_id; ?> {exp:query sql="{$Sql}” }

The following is the error message I am getting:

Parse error: syntax error, unexpected T_VARIABLE, expecting ‘(’ in /home/……./libraries/Functions.php(656) : eval()’d code on line 19

The goal I am trying to get to is to have the table name’s prefix be dynamic, allowing us to use the same table name with a different prefix, depending upon the environment we are in ( Dev_, Tst_, Prd_). This allows us to use ONE MySQL database with multiple environments within it.

I also tried to echo the php variable in exp:query, but received the same error as above. {exp:query sql="<?php echo $Sql; ?>" }

I am just about ready to perform the SQL via PHP to resolve this issue, but my preference its to use exp:query if possible.

Thanks in advance for your assistance!

Lester

       
lcallif's avatar
lcallif
25 posts
14 years ago
lcallif's avatar lcallif

Please consider this issue closed. There was an issue in the code which made EE believe it was in this section…. I did not have the single quotes paired.

Thanks!

       

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.