Posted by Jerry Stuckle on 11/17/06 18:47
gzerphey wrote:
> Thank you in advance for helping.
>
> I have a bit of a problem with MySQL and PHP working together. More
> specifically when i use htmlspecialchars() to encode my text then load
> it into the database, it is interpreting the special characters and
> decoding them.
>
> Is there any way that I can perserve this coding and make sure it says
> in my database?
>
> Example:
>
> Here is what is entered -- t%20t
> Here is what is showing in the database now -- t t
> here is what I would like to see -- t%20t
>
> Thank you again,
>
htmlspecialchars() is for displaying special characters, not storing
them in the database. You should be using it to display the data, not
place it in the database.
What you should do is store the data as is entered (use
mysql_real_escape_string() to handle any database-specific special
characters).
Then when you pull it out of the database, you can use
htmlspecialchars() before displaying the data.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|