Solved

cfquery and LIKE problem

Posted on 2008-10-19
9
432 Views
Last Modified: 2013-12-24
Hello experts.
I have a search page with a search form where i can check more than 1 one checkboxes with the same name but different values.

What like must be the query in the result page to get the items with Kat_ID =7 and items with Kat_ID =2
and items with Kat_ID =4 if i would check the three boxes.
The test query i have don't work:(i have no results)
<cfquery name="artikel" datasource="#dsn#">
SELECT Kat_ID
 WHERE
<cfif isdefined("Url.S_Kat_ID") AND Url.S_Kat_ID NEQ "">      
   Kat_ID LIKE <cfqueryparam value="#URL.S_Kat_ID#" cfsqltype="cf_sql_numeric">
      </cfif>
</cfquery>        
<input name="S_Kat_ID" type="checkbox" id="S_Kat_IDvan" value="7" />

<input name="S_Kat_ID" type="checkbox"id="S_Kat_IDPU" value="2" />

<input name="S_Kat_IDPU" type="checkbox"id="S_Kat_IDKB" value="4" />

Open in new window

0
Comment
Question by:Panos
  • 5
  • 4
9 Comments
 
LVL 9

Expert Comment

by:Andrew Maurer
Comment Utility
Couple things..

I see your three values.. one is not the same name as the other two.. S_Kat_IDPU

Also.. you are checking if a variable is defined and whats its value is... if the variable was not defined, your if statement would throw a error.

AND.. use the IN operator

<cfif isdefined("Url.S_Kat_ID")>

    <cfif Url.S_Kat_ID NEQ "">      

        Kat_ID IN (<cfqueryparam value="#URL.S_Kat_ID#" cfsqltype="cf_sql_integer" list="yes">

    </cfif>

</cfif> 

Open in new window

0
 
LVL 9

Accepted Solution

by:
Andrew Maurer earned 500 total points
Comment Utility
correction... missing right paren )
<cfif isdefined("Url.S_Kat_ID")>

    <cfif Url.S_Kat_ID NEQ "">      

        Kat_ID IN (<cfqueryparam value="#URL.S_Kat_ID#" cfsqltype="cf_sql_integer" list="yes">)

    </cfif>

</cfif>

Open in new window

0
 
LVL 2

Author Comment

by:Panos
Comment Utility
Hi again Zadoc.
The IN operator is not working and i have error.
0
 
LVL 9

Expert Comment

by:Andrew Maurer
Comment Utility
what is the error?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 2

Author Comment

by:Panos
Comment Utility
[Macromedia][SQLServer JDBC Driver][SQLServer]Line 34: Incorrect syntax near '@P2'.


0
 
LVL 2

Author Comment

by:Panos
Comment Utility
The error occurred in C:\Inetpub\wwwroot\car&home7\resultscheck.cfm: line 107

105 : <cfif isDefined ("Url.S_Mobile_Sub_ID")>
106 :     <cfif   Url.S_Mobile_Sub_ID>  
107 :  AND  a.Mobile_Sub_ID = <cfqueryparam value="#URL.S_Mobile_Sub_ID#" cfsqltype="cf_sql_numeric">
108 :       </cfif>
109 :    </cfif>
0
 
LVL 9

Expert Comment

by:Andrew Maurer
Comment Utility
for your second comment.. you haVe this
<cfif   Url.S_Mobile_Sub_ID>

maybe...
<cfif   Url.S_Mobile_Sub_ID NEQ "">
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
Stop looking at.
I did the mistace.I forgot the () in the last code you did post in the other question.
Thank you very much
0
 
LVL 2

Author Closing Comment

by:Panos
Comment Utility
Thank you again for your help.
I will be back.
I hope you will help me again
regards
panos
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now