Jump to content

My query fails only when value is like = '%CI%'


brownbag
Go to solution Solved by brownbag,

Recommended Posts

The following code is a pretty simple select doing a like and is run a few times a week with different two character values in $cclike (surrounded by %, as in '%GA%'. Yesterday it failed unexpectedly when $cclike ended up being equal to '%CI%'. I can repeat this error as much as I want but only when the value of $cclike is equal to '%CI%'.

<? php
$stmt = $pdo->prepare("SELECT consignor_code FROM consignors WHERE store_id =:sid and consignor_code LIKE :cc ORDER BY consignor_code DESC LIMIT 1");
$stmt->execute(['sid' => $store_id, 'cc' => $cclike]);
$consignor = $stmt->fetch();
?>

Does anybody know what it is about CI that is causing this issue? Is it some form of keyword that breaks the query.
Note that I can run the query with outside the php and it works fine. i.e.,

SELECT consignor_code 
FROM consignors 
WHERE store_id ='001' and consignor_code LIKE '%CI%' 
ORDER BY consignor_code DESC LIMIT 1;

 

Link to comment
Share on other sites

  • 3 weeks later...
  • Solution
On 2/26/2023 at 12:54 PM, kicken said:

What is the error, specifically?

On 2/26/2023 at 12:54 PM, kicken said:

What is the error, specifically?

Sorry for the slow response.  I didn't get an error but set up try/catch on someone else's advice and found the problem.  Cheers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.