Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFQuery and returning values

New Here ,
Jun 24, 2008 Jun 24, 2008
I need help querying a database based on the current user signed in (right now we will put the user in the code itself i.e. if username = swat4 and this value = whatever) and then return true if those conditions apply so I can use a cfif to determine what content to display.

The datasource is SiteAdmin. The Table is WWWAdminTable. And the fields include NTUsername, LASNav, WWWNav, EngNav, BusNav, Control. These fileds are mainly a 0 or 1 value, 1 meaning they have permission to view that navigation page.

Here's the code I have started, but I feel it might be going in the wrong direction. I need to know how I can use what I have to query the database, if a username there exists, and the value of (let's say WWWNav) is 1, then using a cfif statement say something like - cfif query getPermissions = true. Please help and thank you.


<cfquery name = "getPermissions" datasource = "SiteAdmin">
SELECT NTUsername, LASNav, WWWNav, EngNav, Control
FROM WWWAdminTable
WHERE

<cfquery>
658
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 24, 2008 Jun 24, 2008
hum,

it would be something of the type?

<cfquery name="getPermissions" datasource="SiteAdmin">
SELECT NTUsername, LASNav, WWWNav, EngNav, Control
FROM WWWAdminTable
WHERE NTUsername = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.NTUsername#">
<cfquery>

<cfif getPermissions.recordCount GT 0>
it's ok :-D
<cfelse>
no ok! :-(
</cfif>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2008 Jun 24, 2008
I received this error:

Element NTUSERNAME is undefined in FORM.

WHERE NTUsername = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.NTUsername#">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 24, 2008 Jun 24, 2008
Hi swat4,

yes, you need a form to pass this value and later to compare.
where the user will enter with the variable for comparison in the database?
substitute the variable form for the which you are using to rescue this value.
Example:
<cfset variables.txtNTUsername = "username valid is here"/>

<cfquery name="getPermissions" datasource="SiteAdmin">
SELECT NTUsername, LASNav, WWWNav, EngNav, Control
FROM WWWAdminTable
WHERE NTUsername = <cfqueryparam cfsqltype="cf_sql_varchar" value="# variables.txtNTUsername#">
<cfquery>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2008 Jun 24, 2008
i'm not following what <cfset variables.txtNTUsername = "username valid is here"/> is.

where is variables.txt coming from.

sorry i'm having a rough day with this stuff, but thanks for the help
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 24, 2008 Jun 24, 2008
LATEST
swat4, my english is not of the best, but for you to verify in the database accordingly a certain value, you receive a parameter and later compare.
This parameter can come from a form or of a defined variable. It gave to understand?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 24, 2008 Jun 24, 2008
Well, did you set a form variable named NTUsername anywhere?

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources