brownbag Posted February 26, 2023 Share Posted February 26, 2023 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; Quote Link to comment https://forums.phpfreaks.com/topic/315949-my-query-fails-only-when-value-is-like-ci/ Share on other sites More sharing options...
kicken Posted February 26, 2023 Share Posted February 26, 2023 22 minutes ago, brownbag said: I can repeat this error as much as I want What is the error, specifically? Quote Link to comment https://forums.phpfreaks.com/topic/315949-my-query-fails-only-when-value-is-like-ci/#findComment-1606031 Share on other sites More sharing options...
Solution brownbag Posted March 13, 2023 Author Solution Share Posted March 13, 2023 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. Quote Link to comment https://forums.phpfreaks.com/topic/315949-my-query-fails-only-when-value-is-like-ci/#findComment-1606513 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.