Page 1 of 1
Converting ’ to a '
Posted: Thu Feb 10, 2005 1:02 am
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

Posted: Thu Feb 10, 2005 1:15 am
by feyd
it's a charset issue, either inserting in or retrieval or both.
...
Posted: Thu Feb 10, 2005 1:26 am
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.
Re: ...
Posted: Thu Feb 10, 2005 1:43 am
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.
Posted: Fri Feb 11, 2005 6:18 am
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
