Replace Suddenly doesn"t work...

Replace Suddenly doesn"t work...

am 22.01.2008 17:06:31 von 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

Re: Replace Suddenly doesn"t work...

am 22.01.2008 17:18:23 von reb01501

doar123@gmail.com wrote:
> 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 ...

--
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.

Re: Replace Suddenly doesn"t work...

am 22.01.2008 17:25:40 von 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

Re: Replace Suddenly doesn"t work...

am 22.01.2008 17:31:50 von Anthony Jones

wrote in message
news:e30d6392-ccaa-4a6c-a957-a5645bec7fe3@e10g2000prf.google groups.com...
> 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 '


--
Anthony Jones - MVP ASP/ASP.NET

Re: Replace Suddenly doesn"t work...

am 22.01.2008 17:51:09 von Dave Anderson

doar123@gmail.com wrote:
> 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.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Re: Replace Suddenly doesn"t work...

am 22.01.2008 17:53:26 von reb01501

doar123@gmail.com wrote:
> 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?

--
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.

Re: Replace Suddenly doesn"t work...

am 22.01.2008 17:56:01 von doar123

On 22 ינואר, 18:31, "Anthony Jones" ada.com> wrote:
> wrote in message
>
> news:e30d6392-ccaa-4a6c-a957-a5645bec7fe3@e10g2000prf.google groups.com...
>
>
>
>
>
> > 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 =3D zofim_rs
> > TempStr =3D Replace(TempStr, """", """,1,-1,1)
> > TempStr =3D Replace(TempStr, "'", "’",1,-1,1)
> > rQuote =3D TempStr
> > else rQuote =3D ""
> > 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 funct=
ion 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 =3D Replace(zofim_rs, """", """)
>         rQuote =3D Replace(rQuote , "'", "'")
>     Else
>         rQuote =3D ""
>     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 '
>
> --
> Anthony Jones - MVP ASP/ASP.NET-הסתר טק=D7=
¡×=98 מצוטט-
>
> -הראה טקסט מצו=D7=
˜×=98-

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

Re: Replace Suddenly doesn"t work...

am 22.01.2008 19:00:06 von doar123

On 22 ינואר, 18:56, doar...@gmail.com wrote:
> On 22 ינואר, 18:31, "Anthony Jones" ayada.com> wrote:
>
>
>
>
>
> > wrote in message
>
> >news:e30d6392-ccaa-4a6c-a957-a5645bec7fe3@e10g2000prf.googl egroups.com...=

>
> > > 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 =3D zofim_rs
> > > TempStr =3D Replace(TempStr, """", """,1,-1,1)
> > > TempStr =3D Replace(TempStr, "'", "’",1,-1,1)
> > > rQuote =3D TempStr
> > > else rQuote =3D ""
> > > 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 fun=
ction in
> > a little VBS and run a few test test string throught it?  What is t=
he
> > result?
>
> > Personally I prefer to use Server.HTMLEncode to do this sort of thing bu=
t
> > your code would work ok as well with the tweaks below:-
>
> > Function rQuote(zofim_rs)
> >     If Len(zofim_rs) > 0 Then
> >         rQuote =3D Replace(zofim_rs, """", """)=

> >         rQuote =3D Replace(rQuote , "'", "'")
> >     Else
> >         rQuote =3D ""
> >     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 '
>
> > --
> > Anthony Jones - MVP ASP/ASP.NET-הסתר טק=D7=
¡×=98 מצוטט-
>
> > -הראה טקסט מצו=D7=
˜×=98-
>
> 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-הסתר טקסט מצו=
טט-
>
> -הראה טקסט מצו=D7=
˜×=98-

Dear Bob,

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

==================== =====3D=
==================== =====3D


<%@Language=3DVBScript Codepage=3D"1255"%>

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

sql=3D"select * from tbl where id=3D14809"
rs.Open sql, DB,0,1
%>
">

==================== =====3D=
==================== =====3D

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


Ilay

Re: Replace Suddenly doesn"t work...

am 22.01.2008 19:20:51 von reb01501

doar123@gmail.com wrote:
> 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
> %>
> ">
>
> ==================================================
>
> 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

%>
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.

Re: Replace Suddenly doesn"t work...

am 22.01.2008 19:32:34 von doar123

On 22 ינואר, 20:20, "Bob Barrows [MVP]" Oyahoo.SPAMcom>
wrote:
> doar...@gmail.com wrote:
> > Dear Bob,
>
> > Here is the code of  the page you can find here:
> >http://www.zofim.org.il/test.asp
>
> > ==================== =====
==================== =====3D=
=3D
>
> > <%@Language=3DVBScript Codepage=3D"1255"%>
>
> > <%Function rQuote(zofim_rs)
> >     If Len(zofim_rs) > 0 Then
> > rQuote=3Dserver.htmlencode(zofim_rs)
>
> Oh! You've switched to using htmlencode!
>
> >     Else
> >         rQuote =3D ""
> >     End If
> > End Function
>
> > sql=3D"select * from tbl where id=3D14809"
> > rs.Open sql, DB,0,1
> > %>
> > ">
>
> > ==================== =====
==================== =====3D=
=3D
>
> > 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=3DVBScript Codepage=3D"1255"%>
>
> <%Function rQuote(zofim_rs)
>     If Len(zofim_rs) > 0 Then
> rQuote=3Dserver.htmlencode(zofim_rs)
>     Else
>         rQuote =3D ""
>     End If
> End Function
>
> %>
> > 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

Re: Replace Suddenly doesn"t work...

am 22.01.2008 20:03:44 von 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

wrote in message
news:cceacd83-3c7d-4240-8af9-3ac129b15d2f@n20g2000hsh.google groups.com...
On 22 ?????, 20:20, "Bob Barrows [MVP]"
wrote:
> doar...@gmail.com wrote:
> > 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
> > %>
> > ">
>
> > ==================================================
>
> > 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
>
> %>
> > 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

Re: Replace Suddenly doesn"t work...

am 22.01.2008 20:20:40 von reb01501

doar123@gmail.com wrote:>
> 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 ...
--
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.

Re: Replace Suddenly doesn"t work...

am 22.01.2008 20:55:17 von doar123

On 22 ינואר, 21:20, "Bob Barrows [MVP]" Oyahoo.SPAMcom>
wrote:
> doar...@gmail.com wrote:>
> > 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 ...
> --
> 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 "
" 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