/    Sign up×
Community /Pin to ProfileBookmark

Characters Encoded Incorrectly

Hi guys, really hoping someone can help me out because I’m pulling my hair out over this!!

My boss keeps writing texts in Word and forwards it on to me to post to our website which I’ve built but when he puts apostrophies in, they get turned into the wierd characters. The text is inserted into a database by PHP and the apostrophy looks like this in the database… ’

I am posting the input to the db in the following way…

[code=php]
mysql_query(“INSERT INTO table VALUES (
‘”.mysql_real_escape_string($text).”‘
)”) or die (mysql_error());
[/code]

Hope someone can help…

Thanks in advance

Smithster

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 18.2012 — Something I came up with some time ago you could try: http://www.charles-reace.com/blog/2008/10/15/filtering-ms-word-text/

Note that in this function I also handle the characters converted by htmlspecialchars(), so you don't want to use it in conjunction with that function (or with htmlentities(), for that matter).
Copy linkTweet thisAlerts:
@smithsterauthorFeb 18.2012 — wow thanks Nogdog for a quick response...

I posted this question on a different forum last night and hadn't had a response back until funny enough just before you! I was told to try this...

[code=php]
mysql_real_escape_string(mb_convert_encoding($text,'HTML-ENTITIES','UTF-8'))
[/code]


It works for the apostrophy I was having trouble with, but I think I'll make use of the function on the page you linked also just incase any other wierd characters end up in there!!

Thanks again ?
×

Success!

Help @smithster spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...