Thread

EE Variable inside Query

August 02, 2017 2:23pm

Subscribe [3]
  • #1 / Aug 02, 2017 2:23pm

    ucview

    1 posts

    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}

  • #2 / Aug 29, 2017 6:19am

    JT Thompson's avatar

    JT Thompson

    745 posts

    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.

  • #3 / Aug 29, 2017 6:25am

    JT Thompson's avatar

    JT Thompson

    745 posts

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

  • #4 / Aug 29, 2017 6:27am

    JT Thompson's avatar

    JT Thompson

    745 posts

    Note to @Derek:

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

  • #5 / Aug 29, 2017 12:10pm

    Derek Jones's avatar

    Derek Jones

    7176 posts

    Hey JT, can you email me what you’re seeing being parsed? Thanks!

ExpressionEngine News

#eecms, #events, #releases