MySQL LIKE Function Not Working

I've got a really weird situation here. I'm building a
dynamic query to a MySQL database that uses the like operator in
the WHERE clause. It seems that for whatever reason, the LIKE part
isn't working. Here's the query:
SELECT DISTINCT model, makeID, engineID, partnum_oem,
partnum_goodyear, partnum_tendeco, partnum_gates, app_desc,
app_type, app_comment
FROM part
WHERE (year = '#attributes.year#')
<cfif attributes.make NEQ "">AND (makeID LIKE
'%#attributes.make#%')</cfif>
<cfif thisModel NEQ "">
AND (model LIKE '%#TRIM(ReplaceNoCase(thisModel, "|", "%' OR
model LIKE '%", "ALL"))#%')
</cfif>
<cfif thisEngine NEQ "">
AND (engineID LIKE '%#TRIM(ReplaceNoCase(thisEngine, "|",
"%' OR engineID LIKE '%", "ALL"))#%')
</cfif>
ORDER BY makeID, model
I turned on the debug output and here is the query it is
passing:
SELECT DISTINCT model, makeID, engineID, partnum_oem,
partnum_goodyear, partnum_tendeco, partnum_gates, app_desc,
app_type, app_comment FROM part WHERE (year = '2006') AND (makeID
LIKE '%Sterling%') AND (model LIKE '%L9500 Series%' OR model LIKE
'%L-Line%') AND (engineID LIKE '%Detroit Diesel Series 60 Diesel%')
ORDER BY makeID, model
Now, If I paste this query into NaviCat, it works perfectly
and returns the 3 expected results. If I replace the dynamic query
in the CF code with the static query, it works fine and gives me 3
results. However, when built dynamically, I get 0 results. Also
weird is that the values of the above query are exact matches for
what's in the DB (the LIKE part shouldn't even come into play!) and
still no results.
This is all run inside a custom tag, but I can see the
results directly through debug. I've used LIKE many times without
issue before, and obviously the query is right since it works when
hard-coded.
We are using CF 7.0.2 on Windows 2003 and MySQL 5.0 with the
J-Connector driver. I also tried this same code to the same data on
a MySQL 4.1 database using the CF built in driver for MySQL and got
the same result.
Anybody have any ideas?

I've never used REQUEST, but from what I understand it's just a generic way of saying $_GET or $_POST. Here a note from http://php.benscom.com/manual/en/reserved.variables.request.php
"Note: The variables in $_REQUEST are provided to the script via the GET, POST, and COOKIE input mechanisms and therefore could be modified by the remote user and cannot be trusted. The presence and order of variables listed in this array is defined according to the PHP variables_order configuration directive. "
Rule of thumb is if you are retrieving any data from an external source such as a form or $_GET, you should assume that the data might not be as you expect it. Hackers can manipulate data sent to your website to gain access to your database. So, never trust it.
e.g if you have a name field, and some ones name is O'Reily and your insert statement looks like this - 'INSERT INTO ....'  the ' between O & Reily would mess up your query as it will assume that ' marks the end of the query. Therefore you need to use a function called addslashes to the posted variable:
e.g
$name = addslashes($_POST['name']); // outputs O\'Reily
there are many ways to clean your data, I always write a function to clean $_GET & $_POST.
e.g $name = clean_data($_POST['name'];  where clean_data processes the data and returns a sanitised version.
do a google search for 'php sanitize/sanitise data', there are thousands of simple solutions to protecting your data.
Chris

Similar Messages

  • Why is the scroll function not working after accessing the voice feature in settings?

    Why is the scroll function not working after accessing the voice feature in settings?

    For some prerecorded audio files the Transpose slider will not work reliably. I found no clear pattern, when it does and when not.
    If all fails, create a loop from the audio file. Select the region in the track and use the command "File: Add region to Loop library".
    Set the current key and tempo, name the loop, and save the loop.
    Now add it from the loop browser to a new track and delete your old track. The search field in the Loop browser will help you to find the loop quickly.
    You will be able to transpose the sample as described above, like a regular loop.
    For example - a audio file turned into a loop and transposed:

  • Why is my touch screen function not working when using facetime

    Why is my touch screen function not working when using facetime

    Hello megascones,
    After reviewing your post, it sounds like the screen is not responding to touch in one app. I would recommend that you read this article, it may be able to help the issue.
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Restart your device. If you can't restart, reset your device.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Not able to sign into Blackberry Protect. Backup and Restore function not working. "Your device isn't associated with a Blackberry ID"

    Not able to sign into Blackberry Protect.  Backup and Restore function not working. Message is: "Your device isn't associated with a Blackberry ID."  My Blackberry Messenger and Blackberry World is working fine so I am sure its not an ID issue on the phone.  I can sign into Link, Blackberry.com and Protect.  I see my device in Protect but cannot send messages or view it on a map.  Times out with cannot reach device message.  BB Protect on Device has a swirling circle beside the on/of switch.  Cannot turn off.  
    I have deleted Link and re-installed.
    I have reset phone to default(factory) and signed in. 
    OS level is 10.2.1.3062
    BB Link is 1.2.3.56
    Solved!
    Go to Solution.

    I managed to figure this out myself. I had to delete the device from the Blackberry Protect website.  protect.blackberry.com.  I wiped my device again and signed in with my Blackberry ID.  I dont know if the step of wiping was necessary as I did not try my backup with the current configuration on the device following the delete.  Restore is in progress for me!

  • Copy/paste function not working in Firefox 22. Always good in previous versions

    Copy/paste function not working in Firefox 22. Always good in previous versions editions

    Well I've uninstalled FF22, thanks for the suggestion.
    Chrome works perfectly with ZA and C&P.

  • MDX -Children count function Not working in Case statement

    Hi,
    I am trying to create set when you slice with the Hierarchy member is leaf level , I want a output only that Leaf level .
    and When I slice with  the parent level , it has to give all the members below that parent level.
    But the problem here is when I select child member or leaf member , The first condition in the Case is not working
    WITH SET
    TESTSET AS
    CASE
    WHEN
     [Dimension].[Hierarchy].currentmember.children.count<0
    THEN
     [Dimension].[Hierarchy].currentmember
    ELSE
     DESCENDANTS([Dimension].[Hierarchy].Currentmember,,AFTER)
    END
    SELECT
    WBSSET ON 1,
    {} on 0
    FROM
     (SELECT {[Dimension].[Hierarchy].&[10]} ON COLUMNS FROM [CubeName])
    Thanks,
    Santosh

    Hi Santosh,
    I don't think Children count function not working in case statement, I have tested it on my local environment, here s the sample query for you reference.
    with member
    testset as
    case
    when
    [Geography].[Geography].currentmember.children.count<10
    then "X"
    else "OK"
    end
    select testset on 0,
    {[Geography].[Geography].[Country].members} on 1
    from
    [Adventure Works]
    In your scenario, the issue might be caused by the query isself, you can try to use IsLeaf Funcion to achieve your requirement. Please refer to the links below.
    http://msdn.microsoft.com/en-us/library/ms144932.aspx
    http://www.databasejournal.com/features/mssql/article.php/3633696/MDX-Operators-The-IsLeaf-Operator--Conditional-Logic-within--Calculations.htm
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=22
    Regards,
    Charlie Liao
    TechNet Community Support

  • Palm Desktop 6.2.2. and Lookup function not working in Windows 7

    Palm Desktop's lookup function not working in Windows 7 64bit. Please help.
    Post relates to: Centro (Verizon)
    This question was solved.
    View Solution.

    I was able to solve this by unchecking compatibility mode and setting the application to run as administrative.

  • Send & Recieve functionality not working with  WebDav after installing Acrobat XI

    Send & Recieve functionality not working with  WebDav after installing Acrobat XI for PDF.  Acrobat XI is complete installations(Trial Version).

    Hi Kiro ,
    Did you try opening that file in any other browser ?If not ,please try doing that once and see if that  works for you.
    Try Repairing Acrobat once and see if  that helps.
    Launch Acrobat>Navigate to Help>Repair Acrobat Installation.
    Regards
    Sukrit Dhingra

  • Like is not working with substr...

    Hello,
    I am trying to do
    FOR i IN (SELECT grp.group_id
                   FROM ems.groups grp, ems.groups_loc gl, ems.location loc
                  WHERE grp.group_id = gl.group_id
                    AND loc.loc_id = gl.loc_id
                    AND gl.loc_id = i_loc_id
                    AND (UPPER(group_desc) LIKE (UPPER(SUBSTR (location_desc, 3,INSTR(SUBSTR(location_desc,3,LENGTH(location_desc)),',')-1)) || ' IT')
                     OR  UPPER(group_desc) LIKE (UPPER(SUBSTR (location_desc, 3,INSTR(SUBSTR(location_desc,3,LENGTH(location_desc)),',')-1)) || ' FACILITIES' ))
                  ) LOOP
    Here there is data with UPPER(SUBSTR (location_desc, 3,INSTR(SUBSTR(location_desc,3,LENGTH(location_desc)),',')-1)) || ' IT') as well as (UPPER(SUBSTR (location_desc, 3,INSTR(SUBSTR(location_desc,3,LENGTH(location_desc)),',')-1)) || ' FACILITIES' )),
    But it seems to be 'LIKE' is not working.
    Can please anybody help me with this problem.
    Thanks.

    Sorry, for insufficient information.
    here i have location desc as 39 Herndon, VA, 11 Jacksonville, FL, 48 Pittsburgh, PA. From these description i have to get Herndon, Jacksonville, Pittsburgh and then check group_desc = 'HERNDONIT' OR 'HERNDON FACILITIES'.
    I am trying with,
    (UPPER(group_desc) LIKE (UPPER(SUBSTR (location_desc, 3,INSTR(SUBSTR(location_desc,3,LENGTH(location_desc)),',')-1)) || ' IT'|| '%')
                     OR  UPPER(group_desc) LIKE (UPPER(SUBSTR (location_desc, 3,INSTR(SUBSTR(location_desc,3,LENGTH(location_desc)),',')-1)) || ' FACILITIES' || '%' ))
    But its not working correctly. Eventhough there is data i am not getting any row return.
    Thanks,
    Gayatri.

  • Keyboard + mouse functions not working

    After updating InDesign CC 6-days ago started to have issue with all keyboard + mouse functions not working ex. shift key does not constrain proportions when scaling. A restart fixed the issue thr first time. Today I have installed latest update and shut down and restarted several times does not fix issue. On a MacBook pro running OS X Mavericks 10.9.2.

    Disconnected extrenal devices ie keyboard and Wacom Bamboo tablet and restarted computer seemed to correct the issue.

  • In my ipad zoom function not working..some day before it worked,but when i double pinch with my three fingers it zooms negligible, wat to do?plzz help me..

    In my ipad zoom function not working..some day before it worked,but when i double pinch with my three fingers it zooms negligible, wat to do?plzz help me..

    It works when I reset my all settings...
    Settings>general>reset>reset all settings
    It never delete ur all contacts and any others,but ur wallpaper and wifi connection will change..it can be as before...

  • HT204168 touch screen function not working when using facetime

    Why is my iPad touch screen function not working when using FaceTime?

    Hi megascones,
    I apologize, I'm a bit unclear on the exact nature or scope of the issue you are describing. If you are having issues with the touch screen on your iPad, you may find the troubleshooting steps outlined in the following article helpful:
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Regards,
    - Brenden

  • HT1977 I bought apps. My kid delet that after few weeks. Then I have downloaded to same ipad. But some functions not working.

    I purchase some apps, my son deleted some. But I have download again from cloud. But some functions not working ask me to pay again. How can I use functions without paying again.   Thank you

    Search around on the app settings and see if there's a "Restore purchases" option.

  • After upgrading to maverick; help & other functions not working

    After upgrading to maverick; help and other functions not working?

    Sometimes just closing and reopening the Help window will clear up the problem. If it doesn't, log out or restart the computer and try again. Otherwise, you may need to delete the Help cache.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Caches/com.apple.helpd
    Right-click or control-click the highlighted line and select 
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder selected. Move the selected folder to the Trash. Log out, log back in, and test. Help pages will be slow to load at first.
    If that doesn't work, the problem may be caused by network conditions. It may go away by itself, though I can't say how long you should wait.
       A persistent failure to load help data has been reported as an issue with satellite networks. Test on a different network, if possible. I've also seen at least one report that Photo Stream in iCloud can mysteriously interfere with Help. I'm not sure whether that's true, but try disabling Photo Stream, if applicable.*If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combinationcommand-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • "Like" sql function not working  in Business Service

    Hi all,
    I have created a query with few Joins (Processing around 4-5 tables).It has Two scenarios, One with Equals and the other with Like function.
    SELECT
    ST.STREET,
    ST.DECOMPLEMENT,
    ST.STATE,
    LC.LOCALITY,
    DS.DISTRICT,
    ST.CDZIP,
    SP.street_type
    FROM
    STREET ST,
    DISTRICT DS,
    Locality LC,
    Street_Type SP
    WHERE
    ST.CDZIP LIKE ?
    AND ST.STARTDISTRICT = DS.DISTRICT (+)
    AND ST.LOCALITY = LC.LOCALITY (+)
    AND ST.STREET_TYPE = SP.street_type (+)
    When There is an Equal Sign after Where clause, The query gives desired output. But when there is a LIKE it does not give any output at all. How can i use this Query using perform operation.

    Hi Arun,
    How are you using it? Using DB Adapter / X-Query function? I have run similar SQL Queries easily through DB Adapter.
    Regards,
    Anuj

Maybe you are looking for

  • SAP R/3 with JOLT componant

    Hi, Does exist an adpater which permits to connect an R/3 instance to a JOLT agent ? The aim is to avoid the installation of Tuxedo on our server. At this moment we use this : SAP R3 - CLIENT C - tuxedo installed on the R/3 server - we would prefer t

  • BPM design - JDBC - SOAP - JDBC

    Hi experts, Business scenario - Pull the data from Data base using a Stored Procedure(this marks the records once it is successful) and call web service using this data. If web service call is success, push the response received from web service to D

  • Bouncing and filtering mail

    How do I bounce and filter mail in the new Lion mail app?

  • Display conditioned selectbooleancheckbox in table

    Hi Forum, I've requirement that in a table say there are 2 columns 'status' and 'check'. where check column displays as selectbooleancheckbox. 1. If the value of status column is 'done' corresponding check column value is 'NA' 2. If the value of stat

  • After Effects 6 in Mac OS 10.5.8

    I really did search a while before submitting such a mundane question to this forum, but I haven't been able to find this answer anywhere. I've got an old copy of AE 6 that I haven't loaded on a computer in several years. I'd like to run it now, but