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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.