Converting ’ to a '

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
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Converting ’ to a '

Post by robster »

I hope the forums display this properly, but I used htmlspecialchars to covert my strings in a form to their html equivilants then stored them in the mysql database. Now I want to display them on the site, when I call them up from the database he browser is showing them as their html (ie as ’).

I've looked into the php manuals for coverting back to their non html equivilant and it has lots of options, that work for just about all characters... except the ' which is ’ in html.

Does anyone have any ideas?! My brain is squirming on this one!

ta :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's a charset issue, either inserting in or retrieval or both.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

...

Post by s.dot »

this is just a guess... but if you're using mysql_escape_string along with htmlspecialchars, user mysql_real_escape_string instead. This will take into account your charset.
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Re: ...

Post by robster »

scrotaye wrote:this is just a guess... but if you're using mysql_escape_string along with htmlspecialchars, user mysql_real_escape_string instead. This will take into account your charset.
Apologies, but I don't fully understand what you mean here?

This is my code I use to convert the string from the one I capture in the form:

Code: Select all

$new_title = htmlspecialchars("$title", ENT_QUOTES);
Does this give you any clues as to how I can solve the problem? The value of $new_title ends up in the database.

ta :) Thanks for the help.
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

I sorted it with addslashes.

$new_title = addslashes("$title");

This means I don't have to use html stuff anymore. It goes into the database clean and i can pull it out with a bit of html goodness ;)
Post Reply