Web Hosting Talk







View Full Version : Escaping single quote


HighRPM
09-11-2002, 01:40 AM
Did a search already but couldn't seems to find the answer... anyway..

I am having problem with escaping single quote '

I am not sure about this but it appears to me that if I pass a string from one page to another, the characters needed to be escaped will have a backslash add before them automatically.

The problem I am experiencing is that when I use backslash (via addslashes())in a string to escape a single quote, the result I got after passing it thru a hidden form to another page is the string with the added backsalsh getting backslashed ~-~ And everything after the 2 backslashes are missing...

The following demonstartes how I ended up with 2 backslashes:

action: Pass string "I'm a newbie" into another page
result: "I\'m a newbie" get passed into another page

action: use stripslashes() to remove backslash then display the content
result: "I'm a newbie" displayed

action: use addslashes() to add backslash to escape the single quote
result: "I\'m a newbie"

action: pass it onto another page thru hidden form <input type=....... value='$temp'), $temp stores the string
result: attempting to display passed variable $temp and got "I\\" displayed.. everything else disappeared..

I have no idea what's going on but it is really bugging me ~-~

Could someone please help me with this???

prosayist
09-11-2002, 02:05 AM
stripslashes(stripslashes($.. ))

don't know if that helps any cause I really don't understand your situation, but sometimes that's what ya gotta do

Rich2k
09-11-2002, 04:10 AM
I can't remember exactly as I don't get this problem but it could be something to do with magic_quotes enabled or the various derivatives thereof?