Forum Moderators: open

Message Too Old, No Replies

How to escape slashes in TEXT boxes?

         

AthlonInside

2:51 pm on Feb 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assume that I want a TextBox with data

I'm "Superman"

How do I escape the double slashes so the intermediate slashes are not treated as closing slash?

<input type=text value="I'm "Superman"">

AthlonInside

2:54 pm on Feb 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using &quot; doesn't help because I am passing them to MySQL.

hyperbole

6:49 pm on Feb 23, 2004 (gmt 0)

10+ Year Member



It looks as if you are calling this character (') a slash. That is an apostrophe.

If you want to escape the character (') use quotes (") around the string or put a back slant (\) in front of the apostrophe like this (\').

DrDoc

6:51 pm on Feb 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So, to recap:

<input type=text value="I'm \"Superman\""> ...will do it


Now, say that you wanted this text in the box:

A slash looks like this: "\"

How would one go about doing that? :)

<input type=text value="A slash looks like this: \"\\\"">

tombola

9:18 pm on Feb 23, 2004 (gmt 0)

10+ Year Member



A slash looks like this: "\"

Uhmm, isn't that a backslash?

AthlonInside

9:10 am on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, I get the idea.

Sorry, it is definitely not slash, what in my mind is actually 'quote' - single quote and double quote.

/ is a slash
\ is also a slash but back slash.

But as long as we understand each other, do words really matter? :)

hyperbole

5:43 pm on Feb 24, 2004 (gmt 0)

10+ Year Member



as long as we understand each other, do words really matter? :)

I agree. I was just define terms so that I would be sure I was answering the question you asked. :)

AthlonInside

3:20 pm on Feb 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What about this

<a href="somefile.php?data=""">

" inside HREF, how to escape?

tombola

9:21 pm on Feb 26, 2004 (gmt 0)

10+ Year Member



In that case, you must use an urlencoded string (hexadecimal value of the ASCII character):
Here are a few examples:

space (ASCII = 32) = %20
! (ASCII = 33) = %21
" (ASCII = 34) = %22
# (ASCII = 35) = %23
$ (ASCII = 36) = %24
% (ASCII = 37) = %25
& (ASCII = 38) = %26
' (ASCII = 39) = %27
( (ASCII = 40) = %28
) (ASCII = 41) = %29

So, <a href="somefile.php?data="""> must be written as: <a href="somefile.php?data=%22%22">