Solved

Syntax fix

Posted on 2014-04-09
11
163 Views
Last Modified: 2014-04-11
"'CurrentUserID()' OR FIND_IN_SET('office', sharegrpall) OR FIND_IN_SET('" . CurrentUserID() . "', sharegrp)) "

What am I missing here?
0
Comment
Question by:Starquest321
  • 5
  • 3
  • 2
  • +1
11 Comments
 

Author Comment

by:Starquest321
ID: 39989327
There is some issue with syntax
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 167 total points
ID: 39989337
Can you post the whole query?
0
 

Author Comment

by:Starquest321
ID: 39989356
It's actually part of a select statement . . . embed
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39989363
OK. Can you post the php code?
Cause your original code does not really look like php.
0
 

Author Comment

by:Starquest321
ID: 39989367
The code is generated by itself . . . I just create the filter. . . so I just need the part between the quotes
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39989376
I still don't get it.

In php a variable has a $ in front, so sharegrpall and sharegrp have to be constants.
Apart from the fact that it's common practice to name the constants in ALL CAPS, are they defined as constants?

CurrentUserID() has to be a function. Where is it defined and what does it return?
0
 
LVL 21

Assisted Solution

by:Kim Walker
Kim Walker earned 166 total points
ID: 39989413
The first 'CurrentUserID()' is in single quotes so it is probably being handled as a string. The second CurrentUserID() appears to be a function that generates a string that's being concatenated with the the strings before and after it because it is between two dots or concatenate operators.
0
 

Author Comment

by:Starquest321
ID: 39989430
you are in the right direction. . .

userid is an int 11
where as the other two fields are varchar 300 fields.  . .

The error seems to be when I added my self the userid
0
 
LVL 21

Expert Comment

by:Kim Walker
ID: 39989661
Either way, none of this is PHP. It appears that you're using PHP to generate an SQL statement. But you say you're creating a "filter" and you've posted a screen capture of what might be an error that's being generated.

What are you trying to communicate with in PHP, a database? What kind of database? You may want the topic administrator to add the kind of database to the question topic so experts in that topic will know to look at the question.

you are in the right direction. . .
What leads you to believe I'm in the right direction? Have you made a change that lead to a different error? Please post the changed code and how it changed the results.
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 167 total points
ID: 39989697
Based on your other post

http://www.experts-exchange.com/Programming/Languages/SQL_Syntax/Q_28044665.html

shargrpall is a db field that (I assume) contains a comma separated string that could contain the word 'office' or the CurrentUserID()

What you have not made clear is what you are trying to do - the inclusion of CurrentUserId() as a quoted string in the filter is creating confusion - as you are using it as a concatenated value in the same string.

Which is it to be - evaluated by PHP as a function call.

...' . CurrentUserId() . '...

Or as a MySQL interpreted function as
'CurrentUserID() OR ...'

I suspect the former in which case you need to add the item to your filter string as a PHP function call - not as a string

$filter .= CurrentUserId() . ' ... rest of filter';

Having said that - you need to provide more information - you have not made clear what the problem is, what the error is or any other information that would enable a quick solution to the problem. The more information you provide the easier it will be to help you.
0
 

Author Comment

by:Starquest321
ID: 39993427
Perfect. You all helped. Figured it out!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now