ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 29th, 2005, 09:57 PM
dunskii dunskii is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 45 dunskii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 21 m 14 sec
Reputation Power: 4
Am I blind or stupid...Too few parameters

Hello all, I am unsure if i am blind or stupid or may i've just been looking at the problem for too long.

I have a form that allows the user to find businesses on the db (access). They can also select the area and way they want the results to be ordered.

Though I get an error To few parameters Expect 1, which from my experience just means i have made a stupid mistake. It is occuring in the cfif statements that are used to call the appropriate order by.

Strange thing is that i have other searches that use pretty much the same code and work fine.

Thanks for you help

ad

heres the code

Code:
SELECT
	b.business_id,
	b.bus_name,
	b.phone,
	b.address,
	b.zone_id,
	a.area_name,
	sc.sub_cat_name,
	sc.description
FROM
	(sub_category AS sc INNER JOIN business as b ON sc.sub_cat_id = b.sub_cat_id) INNER JOIN area AS a ON b.area_id = a.area_id
WHERE	
	([b].[bus_name] LIKE '%#keyword#%'
OR
	[b].[description] LIKE '%#keyword#%'
OR
	[sc].[sub_cat_name] LIKE '%#keyword#%')	
AND
	([b].[zone_id] = #variables.zone#)	
ORDER BY  
<cfif isDefined("variables.order") AND variables.order EQ "asc">
	b.bus_name ASC
</cfif>
<cfif isDefined("variables.order") AND variables.order EQ "dsc">
	b.bus_name DESC
</cfif>
<cfif isDefined("variables.order") AND variables.order EQ "area">
	a.area_name ASC
</cfif>

Reply With Quote
  #2  
Old May 30th, 2005, 04:43 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
First, always check the SQL that is actually executed by looking at the debugging information. But my first instinct might be that if more than one condition runs you need a comma between each element of the order by clause. You also might have a problem if none of the conditions are met because there will be nothing in the order by clause at all.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old May 30th, 2005, 11:41 PM
dunskii dunskii is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 45 dunskii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 21 m 14 sec
Reputation Power: 4
There will only ever be one order by clause that will always be met.

This is the query that is being passed in the debugging info

SELECT DISTINCT b.business_id, b.bus_name, b.phone, b.address, b.zone_id, a.area_name, sc.sub_cat_name, sc.description
FROM (sub_category AS sc INNER JOIN business as b ON sc.sub_cat_id = b.sub_cat_id)
INNER JOIN area AS a ON b.area_id = a.area_id
WHERE ([b].[bus_name] LIKE '%t%' OR [b].[description] LIKE '%t%' OR [sc].[sub_cat_name] LIKE '%t%' OR [sc].[description] LIKE '%t%') AND ([b].[zone_id] = 1)
ORDER BY a.area_name ASC

I hope that gives you more insight into my problem

Cheers,
AD

Reply With Quote
  #4  
Old May 31st, 2005, 07:53 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
Then the next step should be to run that query in your database's SQL tool. Does it run?

And the next step is to strip away the joins and the likes, and then add them one at a time until you determine which one is causing the problem. It could be a type mismatch, a missing comma, etc.

Reply With Quote
  #5  
Old May 31st, 2005, 07:32 PM
kanutervalve kanutervalve is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 47 kanutervalve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 1 m 34 sec
Reputation Power: 4
Are you sure that #variables.order# is defined??? If it's not defined then you have ORDER BY "" which would throw that same error. Just for grins, why don't you try outputing that variable just on top of where you execute that query to make sure it's set as something. Also, if it is set as something, make sure it's "asc", "dsc", or "area".

Reply With Quote
  #6  
Old June 2nd, 2005, 09:17 PM
dunskii dunskii is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 45 dunskii User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 21 m 14 sec
Reputation Power: 4
I'm stupid, and i'm too embarrased to tell you what caused the error, lets just say it wasn't the code but a db thing... ok i'll tell you i had a table name wrong... i guess lack of sleep make you do dumb mistakes

thanks again, ad

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Am I blind or stupid...Too few parameters


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT