Skip to main content
Known Participant
September 1, 2009
Question

Error with query compairing form entry.

  • September 1, 2009
  • 1 reply
  • 1378 views

Hello;

I wrote a small log in and it is giving me a problem. I use this all the time, and can't figure out why now on a different server it's giving me a hard time.I get an error when I submit the log in form. I can't figure out what I missed and why it decided to give me a problem now.

this is my error:

Error Executing Database Query.

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3.
The error occurred in C:\website\admin\LoginCheck.cfm: line 13
Called from C:\website\admin\index.cfm: line 7
Called from C:\website\admin\LoginCheck.cfm: line 13
Called from C:\website\admin\index.cfm: line 7
11 :  FROM adminUser
12 :  WHERE userName =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userLogin#">
13 :  AND password =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userPassword#">
14 : </CFQUERY>
15 : 

SQLSTATE  07002
SQL   SELECT adminUser.id, adminUser.Fname, adminUser.Lname, adminUser.isAdminstrator, adminUser.userName, adminUser.password FROM adminUser WHERE userName = (param 1) AND password = (param 2)
VENDORERRORCODE  -3010
DATASOURCE  mainDB

This is that block of code from the form to the LoginCheck.cfm block of code.

Form:

<cfif isDefined ("FORM.UserLogin")>
<cfinclude template="LoginCheck.cfm">
</cfif>

<cfform action="#CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#" method="post" name="LoginForm">
     <cfinput type="hidden" name="userLogin_required">
     <cfinput type="hidden" name="userPassword_required">

<cfinput type="Text" name="userLogin"> <!--- there is more to these form fields, I just left it off for now to shortn the code--->

<cfinput type="Password" name="userPassword">

<cfinput name="Submit" value="Login" >

</cfform>

LoginCheck.cfm page:

<cfparam name="FORM.userLogin" type="string">
<cfparam name="FORM.userPassword" type="string">

<CFQUERY NAME="IsValidLogin" datasource="#APPLICATION.dataSource#">
SELECT adminUser.Fname, adminUser.Lname
FROM adminUser
WHERE userName =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userLogin#">
</CFQUERY>
<CFQUERY NAME="IsValidUser" datasource="#APPLICATION.dataSource#">
SELECT adminUser.id, adminUser.Fname, adminUser.Lname, adminUser.isAdminstrator, adminUser.userName, adminUser.password
FROM adminUser
WHERE userName =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userLogin#">
AND password =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userPassword#">
</CFQUERY>

this IsValidUser is the one throwing the error. I have gone over this a million times and don't see what I did wrong. Can anyone see what I might be missing?

Thank you

This topic has been closed for replies.

1 reply

Inspiring
September 1, 2009

Probably a reserved word problem, password.

Also, your cfparam tags don't have default values and your hidden form fields don't have values.

Known Participant
September 1, 2009

I changed the query table to Adminpass and changed my cfparam tags to this:

<cfparam name="FORM.userLogin" type="string" default="#FORM.userLogin#">
<cfparam name="FORM.userPassword" type="string" default="#FORM.userPassword#">

it's still giving me the same error.

could it be a server setting or something? This looks right to me.

Inspiring
September 1, 2009

The default values for your cfparam tags make no sense whatsoever.  I suggest reading the manual to see what that tag actually does.

To debug your query, take out the octothorps.  If it runs and returns zero rows, the problem is with your variables.  If you get the same error, it's with your query.