Skip navigation
Tony290
Currently Being Moderated

Advanced Recordsets

Feb 27, 2013 2:02 PM

I cannot get a $_SESSION variable to work in the advanced recordset below in DW CS5.5. I've sucessfully used this technique quite a bit in SQL "=" statements but cannot get it to work in a SQL "IN" statement. I've create the session variable $_SESSION['coachnos]in program A as "000062,000063" and 000062,000063 and pass it to program B. Neither format works. If I substitue the colname variable with "000062,000063" or 000063,000063 it works. I've spent 2 days of this with no luck.What am I missing? I'd appreciated any advice anyone has. Here's what my advanced recordset looks like.

 

rsCoach.png

 
Replies
  • Currently Being Moderated
    Feb 27, 2013 2:13 PM   in reply to Tony290

    When using the IN predicate, each text item in the list must be quoted individually.

     

    SELECT * from myTable WHERE myColumn IN ('000062', '000063')

     

    Not sure why it works when hardcoded. Can you show us the entire recordset code that is not working?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 27, 2013 4:23 PM   in reply to Tony290

    Echo $query_rsCoach so we can see what the SQL statement looks like after GetSQLValueString processes the parameter.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 27, 2013 11:03 PM   in reply to Tony290

    I don't use PHP, so I don't know - but shouldn't the session variable be enclosed in quotes?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 28, 2013 10:30 AM   in reply to Tony290

    >The session variable is enclosed in single quotes when you create it i.e.

    >$_SESSION['name']. To access it you write $_SESSION[name].

     

    Really? I don't see that in the PHP manual or in any examples. In any case, I know PHP is pretty forgiving (too much if you ask me) about rules, but it's worth a shot if you haven't tried it yet.

     

    Have you verified that your browser is set to allow session cookies?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 1, 2013 11:08 AM   in reply to Tony290

    >I've used this technique successfully plenty of times with SQL WHERE statemtments.

     

    That's because the IN predicate requires that each comma separated value is wrapped in quotes and it is up to you to construct the variable this way -  but it looks like GetSQLValueString() does not handle this properly and tries to escape the quotes. You don't need GetSQLValueString for this - just pass the $colname_rsCoach to sprintf() directly and it should work.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points