|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Thanks that works a treat.
|
|
#4
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > cfif statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|