I am working with an Access database, I already set up the ODBC connection in my PHP code. The problem is, that my database contains some table elements with accents such as : á, è, etc... When creating the SELECT I try to compare what the user selected from a HTML form with what is in the database, but since it has a special character, comparison does not work.
I created a function that converts the unrecognized characters to their original form (UTF-8), but when I compare them in the query they do not match, although the conversion was successful on the client side, but inside the database the characters are still unrecognizable.
This is the function I used to convert the unrecognized characters to UTF-8
function convert($string) {
if (mb_detect_encoding($string, "utf-8, true) === false) {
return mb_convert_encoding($string, "utf-8", "iso-8859-1");
} else {
return $string;
}
}
This works on the client side, but when I compare to the database like this:
SELECT from something FROM somethingelse WHERE '$string' = databasestring;
This does not work because I am comparing "Nuevo León" with "Nuevo Le?n"
I want to compare "Nuevo León" with "Nuevo León" and display the corresponding column