/    Sign up×
Community /Pin to ProfileBookmark

Delete or edit special characters from a string

Dear users,

I want to store in my mysql database some data sent from my website users.

If I try to enter a string like “na 😍”, containing some special characters, I receive this error:
ERROR 1366: 1366: Incorrect string value: ‘xF0x9Fx98x8D’ for column ‘text_se’ at row 1

Now, via PHP I want to edit the string sent by the users, so I can store in the database, or if it isn’t possible, I want to delete those characters from the string.

How to do it?

Thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 14.2019 — What character set are you using for that column in the DB? Maybe you just need to change it to a multi-byte unicode set like UTF8?
Copy linkTweet thisAlerts:
@coleioJul 14.2019 — could he store the icons as images in a folder and use some sort of placeholder in the db column?
Copy linkTweet thisAlerts:
@redagrauthorJul 15.2019 — If I use htmlentities before sending to sql command, will I fix the issue?

Thanks
Copy linkTweet thisAlerts:
@NogDogJul 15.2019 — > @redagr#1606315 If I use htmlentities before sending to sql command, will I fix the issue?

It's a kludge of sorts, in that your data now becomes HTML-specific, versus just being data that represents the actual user input. If you don't feel inclined to fix the database, then it will probably "work". 🤷‍♂️
×

Success!

Help @redagr 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 4.26,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...