Apoostrophes in textarea

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Apoostrophes in textarea

Post by kdidymus »

Long story short, part of the site I'm designing takes input from the user in the form of a textarea and posts the inputted text to a MySQL table.

When you SELECT the data back from the dB, apostrophes are being slashed out (i.e. Wouldn/'t instead of wouldn't) and I don't know how to stop it doing this. The same goes for the pound sterling symbol which is displayed as a square.

I know that the ASCII code for an apostrophe is ' and the ASCII code for a pound sterling symbol is £

Is there any way of having my PHP check the inputted text and convert any apostrophes or sterling symbols with their ASCII equivalent?

Thanks in advance.
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Apoostrophes in textarea

Post by internet-solution »

It looks magicquote is enabled on your server. The easiset thing is to use stripslashes on the data you are receiving from the database.

Re. £ symbol, you can do a preg_replace before inserting data into DB, to replace the £ with its ASCII equivalent.
Post Reply