Perl-Sensitive Sunglasses | |
PerlMonks |
perl dbi mysql and accented charactersby combraxis (Novice) |
on Dec 26, 2021 at 15:24 UTC ( [id://11139912]=perlquestion: print w/replies, xml ) | Need Help?? |
combraxis has asked for the wisdom of the Perl Monks concerning the following question: I have a search function written by me to search a MYSQL database from a website form which calls a php script website is LAMP Centos 7 with WHM the database is MYSQL 5.7.36 fields are utf8_general_ci Database Collation latin1_swedish_ci Database Connection Collation utf8mb4_general_ci perl 5 (revision 5 version 16 subversion 3) the database connection is done like this:
I have inserted a LOG_FILE into the script to check what is happening. the code is intended to search for a surname (which is always uppercase in the database) in four fields of a table named 'g2_Item' checking that the public has access to this file (g2_accessMap.g_permission). The function works fine as long as no accented characters are involved but as soon as an accented character is included (èéêëöüçÈÉËÊÖÜ) the function returns no rows from the database table = 'nothing found' There seem to be 2 problems: 1. The accented characters are not being upcased - but even if the accented character is inclued already upcased, no rows are found - equally the MySQL database is case insensitive. 2. the term submitted for searching in the mysql select is not being found the search term surname appears as it should in the log_file, eg: 'HÖRR' (for which there is an entry in the database). If I copy and use that term from the log_file and use it in an sql query on PHPmysqlAdmin I get around 100 rows including all HORR and HÖRR entries in the database. But when that term is passed by the perl code to mysql the result is 0 rows found. Also I copied a php form and function (https://www.elithecomputerguy.com/2019/12/mysql-search-form-with-html-and-php/) and adapted it for my database - it works fine with accented characters, returning all the rows containing 'HÖRR' or 'HORR'. this is the perl code: -- The log file records the $searchphrase as '%HöRR%' the number of rows found is invariably 0.
Back to
Seekers of Perl Wisdom
|
|