This topic is locked
[SOLVED]

 Syntax of session variables in "filter" (where)

6/21/2011 8:01:05 AM
PHPRunner General questions
D
Dave Lowe author

Hi there!
I am trying to use a session variable in the filter field on the Query page. I don't think I have the right syntax for it to work correctly...

= '".$_SESSION["UserLogin"]"'


Is this the right way to do it? Or is there a better way?
Also, when I put the following into the footer, all I get is the exact text, not the variable....

{php}echo $_SESSION["UserID"];{/php}


I'm not exactly sure what I am doing wrong. Any clues?

C
cgphp 6/21/2011

daveL,
if you need a filter use the "List page: before SQL query" event.
Cheers

CGphp

P
procheck 6/21/2011

You missed the 2nd period - '".$_SESSION["UserLogin"] ."'
Al

D
Dave Lowe author 6/30/2011

Thanks for your help guys. But I am still stuck.
Here is the latest code that I have now put into List page:Before SQL query:



$strWhereClause = whereAdd($strWhereClause, "Solution Consultant = '".$_SESSION["FullName"]."'");


Now I know what the problem is. I have to get the single quotes (') around the two worded column 'Solution Consultant' because of the following:
Error Description: 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 'Consultant = 'David Lowe')' at line 1
SQL query: select count(*) FROM quotes where ((Status = 'Pipeline')) and (Solution Consultant = 'David Lowe')
I have been trying numerous variations for a number of hours now. Can anyone please tell me what the fix is? Many thanks for your help.

C
cgphp 6/30/2011
$strWhereClause = whereAdd($strWhereClause, "`Solution Consultant` = '".$_SESSION["FullName"]."'");
D
Dave Lowe author 7/1/2011

Thank-you, thank-you, thank-you...... :-)


$strWhereClause = whereAdd($strWhereClause, "`Solution Consultant` = '".$_SESSION["FullName"]."'");