They are different characters, hence they will return different. I would suggest a string replacement. When inserting into the database, convert each letter using PHP's htmlentities() function.
If you must, can you also replace the characters before searching.
á is not the same as a. It is a completely different character. That is why it will not match. But, you can use the function I already gave you in my previous post.
PHP Code:
$query = "SELECT * FROM table WHERE column = '" . noAccentString('Mas tarde iré a cenar con mi esposa!') . "'";
EDIT: I forget to add the ñ to the array. You can do that yourself.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Running MySQL 5.1.11 pajaro and pájaro return "pájaro". This is with both latin1_spanish_ci and latin1_danish_ci collation. As a result I can't have both pajaro and pájaro in my database, since it would duplice a row.
Are you running an older version which might be the issue?
So I did some testing. My first thoughts were the file type and I think I am correct. Even saving the file in UTF-8 does not truly save the accent marks. For example, try the following. See if the á shows correctly in the textbox even before submitting. When the Spanish characters are not statically typed into a file, they return correctly from the query.
The query for 'pájaro' is successful and gives the same result with both $_POST and hardcoded text.
The query for 'pajaro' doesn't gives any result for both methods.
The server is running Apache and I told the owners to add an AddDefaultCharset UTF-8 to the .htaccess file. This way the server is sending the information as UTF-8. The file is also saved as UTF-8 in the server side. I don't think file type is a problem.
I see that phpMyAdmin shows "MySQL connection collation utf8_general_ci" I'm thinking that connection collation might be the problem. Has connection collation higher priority than database and field collations?. I thought field collation had the highest priority. I don't understand...
The problem is the file type, which is what I began to expect last night. I opened up a generic text editor and saved it with Western (Windows Latin 1) encoding. Both queries returned perfectly.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
First of all, I'd like to appologize for missing a key (I broke my keyboard half an hour ago, and won't be able to fix it for another week (I'm sure you can see what key is missing)).
You can use regular expressions, I guess.
Code:
SELECT *
FROM aves
WHERE LIKE 'p[áa]j[áa]ro;
Just replace all underscores with the character missing.
Last edited by PeejAvery; March 14th, 2008 at 12:29 PM.
Reason: Replaced all the _
Thanks PeejAvery.
I feel sort of stupid now, though. I just realized, I could simply copy a r from somewhere and use find and replace in notepad, to replace the underscores myself.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.