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

Too few parameters. Expected 1 error

New Here ,
Mar 13, 2007 Mar 13, 2007
OK - I'm relatively new to Coldfusion - I glean and pick up bits from here and there and try to make it work for me - i'm learning. Slowly.

I've got 3 pages:
index.cfm <--> login_process.cfm --> documents/index.cfm

Basically the user enters their email address in index.cfm, login_process.cfm then queries the database, if the email doesn't appear then the user is sent back to index.cfm. If the email is in the database, the user is sent onto documents/index.cfm. Once at welcome.cfm they have a welcome message: <h2>Welcome #FIRSTNAME#</h2> - FIRSTNAME being drawn from the database.

I'm having trouble drawing the FIRSTNAME from the database.

My code from the 3 pages are as follows:

index.cfm
<form action="login_process.cfm" method="post">
<label for="EMAIL">Email:</label>
<input type="text" name="EMAIL" id="EMAIL" class="textfield" />
<input name="submit" type="submit" value="Log In" class="submit" />
</form>

login_process.cfm
<cfquery name="qVerify" datasource="****">
SELECT EMAIL FROM tbl_users WHERE EMAIL = '#EMAIL#'
</cfquery>
<cfif qVerify.RecordCount>
<cfset session.allowin = "True">
<script>
alert("Welcome, you have successfully logged in");
self.location="documents/index.cfm?EMAIL=#EMAIL# ";
</script>
<cfelse>
<script>
alert("Sorry, your email do not appear the database. Please try again.");
self.location="Javascript:history.go(-1)";
</script>
</cfif>

documents/index.cfm
<cfquery name="GetUser" dbtype="DYNAMIC" datasource="****">
SELECT * FROM tbl_users WHERE EMAIL = "#EMAIL#"
</cfquery>
<cfoutput query="GetUser">
<h2>Welcome #FIRSTNAME#</h2>
</cfoutput>

The login works fine, lets legit users though, bounces non-legit users back - but I can't seem to get the documents/index.cfm to draw out the #FIRSTNAME# - I tried to add it to the URL in login_process.cfm ( documents/index.cfm?EMAIL=#EMAIL# ) in the hope that it would pass it through but no luck.

I get the following error:

Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.


I think the error is to do with not being able to find a field in the database, but the request feilds are there... Can anyone help?
TOPICS
Database access
3.9K
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
LEGEND ,
Mar 13, 2007 Mar 13, 2007
In your query, change the double quotes to single quotes.
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 ,
Mar 14, 2007 Mar 14, 2007
quote:

Originally posted by: Dan Bracuk
In your query, change the double quotes to single quotes.


Done this - the error has gone now - however documents/index.cfm page displays but without the <h2>Welcome #FIRSTNAME#</h2>
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
LEGEND ,
Mar 14, 2007 Mar 14, 2007
quote:

Originally posted by: Stale Elvis
quote:

Originally posted by: Dan Bracuk
In your query, change the double quotes to single quotes.


Done this - the error has gone now - however documents/index.cfm page displays but without the <h2>Welcome #FIRSTNAME#</h2>

Do you have de-bugging turned on? How many rows did your query return?
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 ,
Mar 15, 2007 Mar 15, 2007
quote:

Originally posted by: Dan Bracuk
Do you have de-bugging turned on? How many rows did your query return?



How do I turn de-bugging on? This might be a good point to explain I don't have Coldfusion installed on my pc - my site is hosted on a Coldfusion enabled server, thats how I can work with it.
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
LEGEND ,
Mar 13, 2007 Mar 13, 2007
Also, I do not see anyway that you are passing date from the second
template to the third template. HTTP is stateless and form variables
only exist on the action page. You will need to use something to pass
the required data to the next page. With CF you have several options,
URL, Session and Application are the three most common but others
include client, server and form.
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 ,
Mar 14, 2007 Mar 14, 2007
quote:

Originally posted by: Newsgroup User
Also, I do not see anyway that you are passing date from the second
template to the third template.

Sorry, I don't understand, why do i need to pass a date from any of the pages?

quote:

Originally posted by: Newsgroup User
You will need to use something to pass the required data to the next page..

Yup, and I think thats where it's falling dow; I was trying that with this - self.location="documents/index.cfm ?EMAIL=#EMAIL# "

quote:

Originally posted by: Newsgroup User
With CF you have several options, URL, Session and Application are the three most common but others include client, server and form.


Could you ellaborate? or point me in the directions of examples?
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
LEGEND ,
Mar 15, 2007 Mar 15, 2007
I don't know if you are still working on this issue so I will be brief.

fistPage.cfm
------------
<form action="secondPage.cfm" method="post"...>
... various <input...> tags and other form elements ...
<input type="hidden" value="An Example" name="aValue">
<input type="submit" value="Just for Fun" name="Submit Field">
</form>

secondPage.cfm
--------------
<!---
This is the action page as defined in the action property of the form
tag in the previous code. On this page, and only this page, there will
be a structure containing all the data submitted from the previous page
as defined in the <input ...> tags. Since the method property of the
form is 'post' the structure will be named 'form'. If the method was
'get' then the structure will be named 'url'.

This page will link to a third page passing data through the URL as well
as the persistent session and application scopes. These latter two
scopes require a matching <cfapplication ...> tag on ALL pages that will
use them. This tag is usually put into an application.cfm or
application.cfc file so that it is automatically included in all
associated pages.
--->

<cfapplication name="joe" sessionmanagement="yes">

<cfdump var="#form#">
<a href="thirdPage.cfm?aValue=#form.aValue#>
<cfset session.aValue = form.aValue>
<cfset application.aValue = form.aValue>

thirdPage.cfm
-------------
<!---
This is the page access from the link on secondPage.cfm. It will no
longer have the form structure, it will have an url structure from the
link as well as the session and application structures utilized in the
previous page.
--->

<cfapplication name="joe" sessionmanagement="yes">

<cfdump var="#form#">
<cfdump var="#url#">
<cfdump var="#session#">
<cfdump var="#application#">
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
LEGEND ,
Mar 13, 2007 Mar 13, 2007
scope your variables!
use #form.EMAIL# in the login_process.cfm and #url.EMAIL# in the
documents/index.cfm
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
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
LEGEND ,
Mar 13, 2007 Mar 13, 2007
also get rid of dbtype="DYNAMIC" in the query in the
documents/index.cfm: use either dbtype=xxx or datasource=xxx but not both
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
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
LEGEND ,
Mar 15, 2007 Mar 15, 2007
Use the cfsetting tag to enable debugging until you don't need it anymore. Then take away the tag.
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 ,
Mar 15, 2007 Mar 15, 2007
I would guess that your query is not returning any rows. (cfdump the value of GetUser.FIRSTNAME and GetUser.recordcount.)

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
New Here ,
Mar 17, 2007 Mar 17, 2007
quote:

Originally posted by: paross1
I would guess that your query is not returning any rows. (cfdump the value of GetUser.FIRSTNAME and GetUser.recordcount.)

Phil


Phil, did a cfdump, and got the following:

<cfquery name="GetUser" datasource="****">
SELECT * FROM tbl_users WHERE EMAIL = '#url.EMAIL#'
</cfquery>
<cfdump var="#GetUser#" label="get user query">

returns no results

but,

<cfquery name="GetUser2" datasource="****">
SELECT * FROM tbl_users
</cfquery>
<cfdump var="#GetUser2#" label="get user query">

returns all the results in the DB - so 'WHERE EMAIL = '#url.EMAIL#'' obviously isn't working...
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 ,
Mar 17, 2007 Mar 17, 2007
LATEST
What is the value of #url.EMAIL# and does it exactly match any values in the EMAIL column? Does #url.EMAIL# have any leading/trailing spaces that need to be trimmed? Is EMAIL case sensitive? Did you CFDUMP #url.EMAIL# and see if it matches your expectations?

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