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

EE Variable inside Query

Development and Programming

ucview's avatar
ucview
1 posts
7 years ago
ucview's avatar ucview

Can someone help me WHY this not working? i cant assign the {logged_in_member_id} as a var to the query. if I manually put the member_id=1 .. it works. but its not reading the {logged_in_member_id} var.

{exp:query sql="SELECT * FROM exp_member_data WHERE member_id='{logged_in_member_id}’”} {m_field_id_7} {/exp:query}

       
JT Thompson's avatar
JT Thompson
745 posts
7 years ago
JT Thompson's avatar JT Thompson

you’re attempting to embed a tag directly into a tag - that can fail.

instead use an embed for the query and pass the tag to it.

example

embed template (embeds/.my_embed) containes:

called like:

(embed="embeds/.my_embed" mid="{logged_in_member_id}"}

Of course you\ll need to check for invalid/blank values (you should be doing that anyway when using exp:query).

Trying to post you the correct code but the forum keeps modifying it (moves my quotes) - hope you get the jist.

       
JT Thompson's avatar
JT Thompson
745 posts
7 years ago
JT Thompson's avatar JT Thompson

finally got it to play nice - code is correct now. 😊

       
JT Thompson's avatar
JT Thompson
745 posts
7 years ago
JT Thompson's avatar JT Thompson

Note to @Derek:

The forum is picking up valid EE tags and outputing their values - I’d call that a security hole. 😉

       
Derek Jones's avatar
Derek Jones
7,561 posts
7 years ago
Derek Jones's avatar Derek Jones

Hey JT, can you email me what you’re seeing being parsed? 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.