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 October 4th, 2005, 05:50 AM
elise_driver elise_driver is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Norwich
Posts: 53 elise_driver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m 10 sec
Reputation Power: 5
Angry cfif statement

Hi,

I have a select statement which checks a number passed over to a primary key in the database.

Question: If the number of passed in the url isn't in the datbase I want to send catch the error and send to a different file.
I'm having problems with the cfif below. (in the code the cfif is obviously below the cfquery) Thanks for your help.

<cfif #q_f.p_ref# NEQ "URL.p_ref">
<cflocation url="success.cfm" addtoken="yes">
</cfif>


<cfquery name="q_f" datasource="spain">
SELECT *
FROM tblogin INNER JOIN
tbproperty ON tblogin.emailaddress = tbproperty.emailaddress INNER JOIN
tbbathroom ON tbproperty.bathid = tbbathroom.bathid INNER JOIN
tbbedroom ON tbproperty.bedid = tbbedroom.bedid INNER JOIN
tbaccom ON tbproperty.accomid = tbaccom.accomid INNER JOIN
tbtown ON tbproperty.townid = tbtown.townid INNER JOIN
tbregion ON tbtown.regionid = tbregion.regionid INNER JOIN
tbtype ON tbproperty.typeid = tbtype.typeid INNER JOIN
tbsleep ON tbproperty.sleepid = tbsleep.sleepid INNER JOIN
tblength ON tbproperty.lengthid = tblength.lengthid
WHERE p_ref = '#URL.p_ref#'
</cfquery>

Reply With Quote
  #2  
Old October 4th, 2005, 08:31 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,651 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 12 h 21 m 47 sec
Reputation Power: 53
You're comparing the variable to the string "URL.p_ref" which will never resolve to true. This should work (note that now you're comparing two variables instead of a variable to a string. Also note that you don't need those pound signs here.)

<cfif q_f.p_ref NEQ URL.p_ref>
<cflocation url="success.cfm" addtoken="yes">
</cfif>
__________________
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 October 4th, 2005, 09:46 AM
elise_driver elise_driver is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Norwich
Posts: 53 elise_driver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 27 m 10 sec
Reputation Power: 5
Thanks that works a treat.

Reply With Quote
  #4  
Old October 4th, 2005, 10:31 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,651 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 12 h 21 m 47 sec
Reputation Power: 53
Just a note that you might consider naming your variables more clearly. In 9 months when you have to look at this code again, you are not going to have any idea what "q_f.p_ref" means.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > cfif statement


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 1 hosted by Hostway