Reputation: 6052
When I post something to my database that have ' or é etc. I get this:
Don't worry guys,
Which should be:
Don't worry guys
This is how I add text to the database:
$text = $_POST['text'];
$text = mb_convert_encoding($text, 'UTF-8', 'UTF-8');
$text = htmlentities($text, ENT_QUOTES, 'UTF-8');
And here is some information about my table in the database:
Format dynamic
Character Set (Sorting) utf8_general_ci
Upvotes: 0
Views: 48
Reputation: 499
Although this is not a good practice to avoid sql injection
use html_entity_decode()
to decode html entites to solve that problem
Upvotes: 1
Reputation: 13649
Use htmlspecialchars()
instead of htmlentities()
to get the result you want in this case:
htmlspecialchars($text, ENT_COMPAT | ENT_HTML401, 'UTF-8')
Upvotes: 1