首页 > 解决方案 > Codeigniter Ajax request With mysql Like query encoding string into characters

问题描述

I have a problem on querying mysql with like query. I am posting a string variable to php and when I echo it as post variable it show me the correct string value but when I insert it in like query it converts the string to a character.

Consider an example I have a query

I am posting $term = 'Felix'

SELECT name, category FROM customers WHERE name LIKE '%{$term}%' OR phone 
LIKE '%{$term}%' OR customerId LIKE '%{$term}%'

when I post term string as felix then it converts the fe to a character.So when i echo this query it show me this reuslt.

SELECT name, category FROM customers WHERE name LIKE 'şlix%' OR phone LIKE 
'şlix%' OR customerId LIKE 'şlix%'

What is the solution to get the like query without encoded character. Note : I have not found any solution here that is why I posted.

标签: phpmysqlsqlajax

解决方案


试试这个,你忘了在 SELECT 之后指定 customerId :)
SELECT name, category, customerId FROM customers WHERE name LIKE '%$lix%' OR phone LIKE '$lix%' OR customerId LIKE '$lix%'


推荐阅读