Replace Suddenly doesn't work...

D

doar123

I'm operating a large web site, and I'm using a function replacing
double qoutes with & quot; in order to present text into a TEXTBOX.

From some unknown reason, the function does not work anymore.

Here it is:

function rQuote(zofim_rs)
if not IsNull(zofim_rs) and len(zofim_rs)>0 then
TempStr = zofim_rs
TempStr = Replace(TempStr, """", """,1,-1,1)
TempStr = Replace(TempStr, "'", "’",1,-1,1)
rQuote = TempStr
else rQuote = ""
end if
end function

does someone know what could be the reason that the function does not
work anymore ?

thanks,

Ilay
 
B

Bob Barrows [MVP]

I'm operating a large web site, and I'm using a function replacing
double qoutes with & quot; in order to present text into a TEXTBOX.

From some unknown reason, the function does not work anymore.

Here it is:

function rQuote(zofim_rs)
if not IsNull(zofim_rs) and len(zofim_rs)>0 then
TempStr = zofim_rs
TempStr = Replace(TempStr, """", """,1,-1,1)
TempStr = Replace(TempStr, "'", "’",1,-1,1)
rQuote = TempStr
else rQuote = ""
end if
end function

does someone know what could be the reason that the function does not
work anymore ?

I assure you it still works. Whether it is doing what you think it
should be doing is another thing. The problem we have is we don't know
what is making you think it is not working. Error messages? Incorrect
results? If the latter, show us some inputs and show us the desired
results as well as the incorrect results.

Perhaps zofim_rs does not contain what you think it contains ...
 
D

doar123

there are no Errors. zofim_rs contains text.

I can see the text in the textbox, Until the double quotes.

Lets say the text is AA"BB
so I can see only AA.

If I print the text outside the textbox, I can see the whole string...

thanks,

Ilay
 
A

Anthony Jones

I'm operating a large web site, and I'm using a function replacing
double qoutes with & quot; in order to present text into a TEXTBOX.

From some unknown reason, the function does not work anymore.

Here it is:

function rQuote(zofim_rs)
if not IsNull(zofim_rs) and len(zofim_rs)>0 then
TempStr = zofim_rs
TempStr = Replace(TempStr, """", """,1,-1,1)
TempStr = Replace(TempStr, "'", "’",1,-1,1)
rQuote = TempStr
else rQuote = ""
end if
end function

does someone know what could be the reason that the function does not
work anymore ?

I would help if defined 'doesn' t work anymore'. Have put the function in
a little VBS and run a few test test string throught it? What is the
result?

Personally I prefer to use Server.HTMLEncode to do this sort of thing but
your code would work ok as well with the tweaks below:-

Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote = Replace(zofim_rs, """", """)
rQuote = Replace(rQuote , "'", "'")
Else
rQuote = ""
End If
End Function

However the only bug I could actually see was &rsquo which is an entity I've
never head of. The DTD entity for an apostrophe is '
 
D

Dave Anderson

I can see the text in the textbox, Until the double quotes.
^^^^^^^^^^^^^^

Learn to view source. The rest of your string ends up as attribute garbage.
 
B

Bob Barrows [MVP]

there are no Errors. zofim_rs contains text.

I can see the text in the textbox, Until the double quotes.

Lets say the text is AA"BB
so I can see only AA.

If I print the text outside the textbox, I can see the whole string...

thanks,
Assuming Anthony's tweak doesn't solve it for you, show us the code for
a small page that reproduces the problem. I'm not clear if that function
is being used in client-side or server-side code. So create a small test
page that does nothing but reproduce this problem - strip everything
else out of it. Post the code here.

To Anthony's point, why not use HTMLEncode?
 
D

doar123

I would help if defined 'doesn' t work anymore'.   Have put the function in
a little VBS and run a few test test string throught it?  What is the
result?

Personally I prefer to use Server.HTMLEncode to do this sort of thing but
your code would work ok as well with the tweaks below:-

Function rQuote(zofim_rs)
    If Len(zofim_rs) > 0 Then
        rQuote = Replace(zofim_rs, """", """)
        rQuote = Replace(rQuote , "'", "'")
    Else
        rQuote = ""
    End If
End Function

However the only bug I could actually see was &rsquo which is an entity I've
never head of.  The DTD entity for an apostrophe is '

Thanks Anthony.

I don't know how to run a little VBS file...

"Doesn't work anymore" means that I used to see in the textbox the
whole string (AA"BB), and suddenly I can see only part of it (AA).
some more Information: about 2 weeks ago, We have formated the server.
There was NO change at the application, the files where Uploaded right
back.
Could the format effect the function somehow ?

another thing: I did another try, changing the function name to
rQuote111 and the problem was solve, I can see the whole string as
desired...
replacing the function on the entire website means 712 Replaces....

Does it make Sence ???

thanks

Ilay
 
D

doar123

Thanks Anthony.

I don't know how to run a little VBS file...

"Doesn't work anymore" means that I used to see in the textbox the
whole string (AA"BB), and suddenly I can see only part of it (AA).
some more Information: about 2 weeks ago, We have formated the server.
There was NO change at the application, the files where Uploaded right
back.
Could the format effect the function somehow ?

another thing: I did another try, changing the function name to
rQuote111 and the problem was solve, I can see the whole string as
desired...
replacing the function on the entire website means 712 Replaces....

Does it make Sence ???

thanks

Ilay-הסתר טקסט מצוטט-

-הר××” טקסט מצוטט-

Dear Bob,

Here is the code of the page you can find here: http://www.zofim.org.il/test.asp

==================================================


<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)
Else
rQuote = ""
End If
End Function

sql="select * from tbl where id=14809"
rs.Open sql, DB,0,1
%>
<input type="text" name="test" value="<%=rQuote(rs("name"))%>">

==================================================

For some reason it DOES work on this page, but not on other
pages..........


Ilay
 
B

Bob Barrows [MVP]

Dear Bob,

Here is the code of the page you can find here:
http://www.zofim.org.il/test.asp

==================================================


<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)

Oh! You've switched to using htmlencode!
Else
rQuote = ""
End If
End Function

sql="select * from tbl where id=14809"
rs.Open sql, DB,0,1
%>
<input type="text" name="test" value="<%=rQuote(rs("name"))%>">

==================================================

For some reason it DOES work on this page, but not on other
pages..........

Well, obviously something is different on those pages, but we have no
way of knowing what.

We have no access to your database, so the sql stuff is irrelevant.
Let's hard-code a test string:

<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)
Else
rQuote = ""
End If
End Function

%>
<input type="text" name="test" value="<%=rQuote("test AA""BB end
test")%>">

It certainly seems to work correctly for me.
 
D

doar123

Oh! You've switched to using htmlencode!



Well, obviously something is different on those pages, but we have no
way of knowing what.

We have no access to your database, so the sql stuff is irrelevant.
Let's hard-code a test string:

<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
    If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)
    Else
        rQuote = ""
    End If
End Function

%>
<input type="text" name="test" value="<%=rQuote("test AA""BB end
test")%>">

It certainly seems to work correctly for me.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Well, I don't know what to say. I'm perplexed.

All I know is that:

1. it worked just fine 2 weeks ago (on hundreds of pages...). beside
formating the server - nothing happened.
2. If I produce a new page, it works, on the older ones - it doesn't.
3. If I use the SAME function, just replacing her name (rQuote >
rQuote111) - It works fine.

thank you for your help. If someone has an creative Idea, please let
me know....

Ilay
 
J

Jeff Dillon

Put in response.write statements in your code to debug and troubleshoot. Or
step through the code in the debugger, if you are using Visual Studio

Jeff

Oh! You've switched to using htmlencode!



Well, obviously something is different on those pages, but we have no
way of knowing what.

We have no access to your database, so the sql stuff is irrelevant.
Let's hard-code a test string:

<%@Language=VBScript Codepage="1255"%>

<%Function rQuote(zofim_rs)
If Len(zofim_rs) > 0 Then
rQuote=server.htmlencode(zofim_rs)
Else
rQuote = ""
End If
End Function

%>
<input type="text" name="test" value="<%=rQuote("test AA""BB end
test")%>">

It certainly seems to work correctly for me.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Well, I don't know what to say. I'm perplexed.

All I know is that:

1. it worked just fine 2 weeks ago (on hundreds of pages...). beside
formating the server - nothing happened.
2. If I produce a new page, it works, on the older ones - it doesn't.
3. If I use the SAME function, just replacing her name (rQuote >
rQuote111) - It works fine.

thank you for your help. If someone has an creative Idea, please let
me know....

Ilay
 
B

Bob Barrows [MVP]

thank you for your help. If someone has an creative Idea, please let
me know....
All I can say is:

You've shown us something that "works", i.e., produces correct results.
Perhaps if you show us a page that is NOT producing correct results ...
 
D

doar123

(e-mail address removed) wrote:>

All I can say is:

You've shown us something that "works", i.e., produces correct results.
Perhaps if you show us a page that is NOT producing correct results ...
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Finally I found the problem.
Thank you very much for your patient.

It found out that I had another function, that replaced "<br>" with v
bcrlf.
the name of that function was also rQuote for some reason.
I changed that, and everything is OK now.

thank you very much again and excuse me for the disturbance.

Ilay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top