PHP/MySQL: Text is truncated before special characters, umlauts, accents
Question by Compi | 2012-10-18 at 22:43
I have a strange problem in a PHP script in which I want to submit a string to a MySQL database:
Although the text is still full in the MySQL query, it does not appear full in the database. Each time the text is truncated just before the first special character (such as an umlaut like ä, ü and ö). Does anyone have any idea what that might be?
Related Topics
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
PHP: Remove arbitrary Characters at the Beginning and the End of a String
Tutorial | 0 Comments
Textarea Maxlength: Limit Maximum Number of Characters in Textarea
Tutorial | 3 Comments
PHP Mail Function: UTF-8 E-Mail Headers
Info | 0 Comments
Lord's Prayer in 20 other Languages
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Most likely the problem is with the character set (the character encoding of the string). Presumably your string is first in ANSI charset and in the MySQL table, it should be stored as UTF-8. There is no difference in the letters from A to Z in these two encodings, so the encoding will only cause problems when using special characters.
In this case you can use the following code:
With this, you change the ANSI encoded text into a UTF-8 encoded text, which you then can use in your MySQL query.
2012-10-19 at 15:10