Copy link to clipboard
Copied
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 : | ||||||||
|
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
Copy link to clipboard
Copied
Probably a reserved word problem, password.
Also, your cfparam tags don't have default values and your hidden form fields don't have values.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I tried a number of different approaches.
I dumped both my variables
<cfdump var="#FORM.userPass#">
<cfabort>
I changed my cfparam tags:
<cfparam name="variables.userName" type="string" default="#FORM.userLogin#">
<cfparam name="variables.adminPass" type="string" default="#FORM.userPass#">
I changed my query taking out the cfqueryparam tags:
<CFQUERY NAME="IsValidUser" datasource="#APPLICATION.dataSource#">
SELECT adminUser.id, adminUser.Fname, adminUser.Lname, adminUser.isAdminstrator, adminUser.userName, adminUser.adminPass
FROM adminUser
WHERE userName ='#FORM.userLogin#'
AND adminPass ='#FORM.userPass#'
</CFQUERY>
I still get this 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 | ||||||
11 : FROM adminUser 12 : WHERE userName =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userLogin#"> 13 : AND adminPass =<cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.userPass#"> 14 : </CFQUERY> 15 : | ||||||
|
I'm stumped. There has to be something small missing here. It works on other servers. Why suddenly not on this one?