Ajax autocomplete not case insensitive - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Ajax autocomplete not case insensitive (/showthread.php?tid=51844) Pages:
1
2
|
Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]zulubanslee[/eluser] I'm doing an ajax autocomplete but it's not case insensitive It's here if you want to look at it: http://golocalseo.net/doug2/bk3/ In the search by city and state, it requires the first letter to be capitalized, since that is how it is in the database naturally. I have used this identical code several times and it has worked fine. This time, no dice but I don't know why. I want the search to be case insensitive. Here is my controller: Code: $q=$_POST["city_string"]; Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]zulubanslee[/eluser] Incidentally, I know you're not supposed to make database calls from the controller, but I wanted to keep it simple until I get it working. Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]zulubanslee[/eluser] Well I decided to try a different tack. I decided to go with writing my own mysql statments, but now my bound parameters aren't working. Here is my controller now. Code: $q=$_POST["city_string"]; This is the error message I got. Code: <p>Error Number: 1064</p><p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' at line 3</p><p>SELECT DISTINCT city, state_name Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]Samus[/eluser] You could use ucwords(). It capitalizes the first letter of every word in a string, then you could send that version of to your query. http://php.net/manual/en/function.ucwords.php Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]zulubanslee[/eluser] It'll work for the time being, but i really want it entirely case insensitive. Thanks for your input. Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]CroNiX[/eluser] Try: Code: SELECT DISTINCT city, state_name Ajax autocomplete not case insensitive - El Forum - 05-20-2012 [eluser]zulubanslee[/eluser] That did not work. Here is what I ended up going with. Code: $q=$_POST["city_string"]; Ajax autocomplete not case insensitive - El Forum - 05-21-2012 [eluser]gRoberts[/eluser] The reason being, is from all of your examples, I have not seen you force the query going in to lower case? So your forcing the column to lower, using the `lower` function in MySQL but your then passing the value to match against in normal case. Instead, pass your value but use `strtolower` to force it to lower case. Ajax autocomplete not case insensitive - El Forum - 05-21-2012 [eluser]zulubanslee[/eluser] You're absolutely right, and what you suggested worked. I've never had to specify case sensitivity before with a select, though. Ajax autocomplete not case insensitive - El Forum - 05-21-2012 [eluser]CroNiX[/eluser] That depends on the datatype and collation of the field. http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html |