This topic is locked
[SOLVED]

 Lookup WHERE:

2/12/2017 4:08:31 PM
PHPRunner General questions
A
admin author

I am trying to lookup a table and filter on the following:
(com_type = 'Vendor' AND global=1) or (com_type = 'Vendor' AND propertyid = " . $_SESSION[$strTableName."_masterkey1"])
I want to display company names where the com_type = "Vendor" and are either global or specific to the property.
I am able to filter the com_type and global successfully:

  • "((global = '1') and (com_type ='Vendor'))"


I am unable to filter the propertyid and com_type

  • "((com_type = 'Vendor') and (propertyid = " . $_SESSION[$strTableName."_masterkey1"]))"
  • "(( propertyid = " . $_SESSION[$strTableName."_masterkey1"]) and (com_type = 'Vendor'))"


And when I try to put it together I receive "syntax error, unexpected ')' in line 1"
"((global = '1') and (com_type ='Vendor'))" or "((propertyid = " . @$_SESSION[$strTableName."_masterkey1"]) and (com_type = 'Vendor'))"
I can not find my error, any help is very much appreciated.
Thanks,

  • Sandy

lefty 2/12/2017



I am trying to lookup a table and filter on the following:
(com_type = 'Vendor' AND global=1) or (com_type = 'Vendor' AND propertyid = " . $_SESSION[$strTableName."_masterkey1"])
I want to display company names where the com_type = "Vendor" and are either global or specific to the property.
I am able to filter the com_type and global successfully:

  • "((global = '1') and (com_type ='Vendor'))"
    I am unable to filter the propertyid and com_type
  • "((com_type = 'Vendor') and (propertyid = " . $_SESSION[$strTableName."_masterkey1"]))"
  • "(( propertyid = " . $_SESSION[$strTableName."_masterkey1"]) and (com_type = 'Vendor'))"
    And when I try to put it together I receive "syntax error, unexpected ')' in line 1"
    "((global = '1') and (com_type ='Vendor'))" or "((propertyid = " . @$_SESSION[$strTableName."_masterkey1"]) and (com_type = 'Vendor'))"
    I can not find my error, any help is very much appreciated.
    Thanks,
  • Sandy



This might help
" . $_SESSION[$strTableName.'_masterkey1']" // for numeric

'" . $_SESSION[$strTableName.'_masterkey1']" . "'" // text

A
admin author 2/13/2017



This might help
" . $_SESSION[$strTableName.'_masterkey1']" // for numeric

'" . $_SESSION[$strTableName.'_masterkey1']" . "'" // text

A
admin author 2/13/2017



This might help
" . $_SESSION[$strTableName.'_masterkey1']" // for numeric

'" . $_SESSION[$strTableName.'_masterkey1']" . "'" // text


Thanks, each one filters correctly by itself.

  • com_type = 'Vendor' - Filters correctly
  • global=1 - Filters correctly
  • propertyid = " . $_SESSION[$strTableName."_masterkey1"] - Filters correctly
  • propertyid = " . $_SESSION[$strTableName.'_masterkey1'] - Filters correctly



If I put them together as per the below they filter correctly.

  • (com_type = 'Vendor' AND global=1) - Filters correctly
  • (com_type = 'Vendor' AND . $_SESSION[$strTableName.'_masterkey1'])-Filters correctly


It is something with the "OR" when combining the 2 above together, I am receiving the error. [b][color="#FF0000"]"syntax error, unexpected ')' in line 1"**

  • "((global = '1') and (com_type ='Vendor'))" or "((propertyid = " . $_SESSION[$strTableName.'_masterkey1']) and (com_type = 'Vendor'))"


Requirement

If Type = "Vendor" AND Global = "1" or Propertyid = "Masterkey1" - Show company name.
Hope this helps explain the challenge I am having.
Thanks,

  • Sandy

Sergey Kornilov admin 2/13/2017

You need to concatenate string and PHP variables properly. The following part is definitely incorrect:

. $_SESSION[$strTableName."_masterkey1"])


Most likely it should be like this:

. $_SESSION[$strTableName."_masterkey1"] . ")
A
admin author 2/13/2017



You need to concatenate string and PHP variables properly. The following part is definitely incorrect:

. $_SESSION[$strTableName."_masterkey1"])


Most likely it should be like this:

. $_SESSION[$strTableName."_masterkey1"] . ")



Thanks Sergey, that removed the syntax error after some thought and practice, I was able to get the following to work.
"((propertyid = " . $_SESSION[$strTableName."_masterkey1"] . ") or (global = '1')) AND (com_type = 'Vendor')"