Monday, December 20, 2010

htmlspecialchars()

So I found the solution to the issue I was having in this blog post.
The problem was that the presence of single quotes in the data string was interfering with the mysql operations. So on googling a little, the solution I got is this php function htmlspecialchars().
You can find a detailed documentation here.

Basically what it did was to convert the:
(single quote) to ''' (along with a second paramater ENT_QUOTES)
which is obviously the dec ascii equivalent.
Other conversions done by this function are:
  • '&' (ampersand) becomes '&'
  • '"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
  • '<' (less than) becomes '<'
  • '>' (greater than) becomes '>'
This is quite useful when dealing with strings that is given to users for adding and editing.
OK, so one big issue solved.

Now, why did I need all this? Coz I am making a web-based custom dictionary for me. Just for fun. If it turns out interesting, I'll inform you guys.
Cya

No comments:

Post a Comment

Recent Articles