/    Sign up×
Community /Pin to ProfileBookmark

help with a select

i am making this select :

[code=php] SELECT * from order_header,users WHERE order_id=’544′ AND firm_id=2 AND (users.user_name=’peleg’ AND find_in_set(’12’,users.dep_list)) ORDER BY order_id DESC[/code]

the thing is that i make a search here on an order_id that another user have made, but i check if my user have prviliges
to access this order_id :

[QUOTE]

(users.user_name=’peleg’ AND find_in_set(’12’,users.dep_list))

[/QUOTE]

the thing is that the query is ok but the name that is return
from the users table is mine and the the original user that made the order!!!
how do i fix it!
thnaks in advance
PEleg

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jabezApr 01.2005 — AND firm_id=2 AND (users.user_name='peleg' AND find_in_set('12',users.dep_list))

.....You have hard-coded your username ^^^ into the query! Is this right?

Maybe you need to change the above to something like:

AND (users.user_name='$any_user' AND find_in_set('12',users.dep_list))

Or just:

AND users.user_name='$any_user'

and then pass the name of the user to the $any_user variable in php, when you are building the mysql query search string.

Try testing out the query by hand first using the mysql monitor, to make sure you are getting the right results returned. Then code the query into the php function that sends the mysql_query() to the database.

HTH - jabez
Copy linkTweet thisAlerts:
@pelegk1authorApr 02.2005 — is just for an example!!!!!

to show where theproblem execly.
×

Success!

Help @pelegk1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...