ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Problem saving entryid list to a session

February 16, 2011 9:05pm

Subscribe [2]
  • #1 / Feb 16, 2011 9:05pm

    chilli_group

    12 posts

    Hi All,

    Developing a Real Estate website and have everything setup except this one part:

    Having a problem with an entry_id list that I’m trying to save to a PHP Session and advanced conditionals.

    Here is the code i’m using to try save a php variable.

    $searchids = '{exp:channel:entries channel="properties" dynamic="no" ' . $searchquery . ' search:property_sold="NO"}{if property_price > ' . $price_min . ' AND property_price < ' . $price_max . '}{entry_id}|{/if}{/exp:channel:entries}';

    $price_min & $price_max are getting the GET value from the URL

    If I perform the same code without the {if} statements, it will save the list fine, but because EE parses the ADVANCED CONDITIONALS last, it doesn’t work.

    I’m using this variable to then save to a session and using ‘entry_id’ list on the individual property pages to create NEXT & PREVIOUS properties links based on the search done on the previous page.

    Any ideas to get around this?
    Thanks for your help in advanced.

  • #2 / Feb 17, 2011 10:07am

    Sue Crocker

    26054 posts

    Hi, chilli_group. Have you considered using the query module for this?

  • #3 / Feb 17, 2011 6:32pm

    chilli_group

    12 posts

    I did try this, but couldn’t get the PHP working inside the Query Module? Is there a trick to this?

    This is what I’ve tried:

    {exp:query sql="SELECT entry_id  FROM exp_channel_data WHERE field_id_17 = '<?php echo $price_min; ?>'"}
    {entry_id}
    {/exp:query}

    But it returns :

    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 ‘’%’ at line 1

    SELECT entry_id FROM exp_channel_data WHERE field_id_17 = ‘

    Filename: modules/query/mod.query.php

    Line Number: 181

  • #4 / Feb 18, 2011 3:56am

    Ingmar

    29245 posts

    Are you running PHP in Input? Does it work when you hardcode $price_min, as it were?

  • #5 / Feb 20, 2011 7:42pm

    chilli_group

    12 posts

    Hi Ingmar,

    Yeah, PHP is set at input. And yes, when I put in a value (eg. ‘3000000’) it works fine, and I can echo $price_min without problems too.

    any ideas?

  • #6 / Feb 21, 2011 2:16am

    chilli_group

    12 posts

    Ok, worked it out. Ended up doing native SQL query though PHP….

  • #7 / Feb 21, 2011 10:56am

    Sue Crocker

    26054 posts

    Sometimes that’s just easier. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases