Replace Suddenly doesn't work...

Discussion in 'ASP General' started by doar123@gmail.com, Jan 22, 2008.

  1. Guest

    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
    , Jan 22, 2008
    #1
    1. Advertising

  2. 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.
    Bob Barrows [MVP], Jan 22, 2008
    #2
    1. Advertising

  3. Guest

    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
    , Jan 22, 2008
    #3
  4. <> wrote in message
    news:...
    > 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, """", "&quot;",1,-1,1)
    > TempStr = Replace(TempStr, "'", "&rsquo;",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, """", "&quot;")
    rQuote = Replace(rQuote , "'", "&apos;")
    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 &apos;


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Jan 22, 2008
    #4
  5. 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.
    Dave Anderson, Jan 22, 2008
    #5
  6. 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.
    Bob Barrows [MVP], Jan 22, 2008
    #6
  7. Guest

    On 22 ינו×ר, 18:31, "Anthony Jones" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > 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, """", "&quot;",1,-1,1)
    > > TempStr = Replace(TempStr, "'", "&rsquo;",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, """", "&quot;")
    >         rQuote = Replace(rQuote , "'", "&apos;")
    >     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 &apos;
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET-הסתר טקסט מצוטט-
    >
    > -הר××” טקסט מצוטט-


    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
    , Jan 22, 2008
    #7
  8. Guest

    On 22 ינו×ר, 18:56, wrote:
    > On 22 ינו×ר, 18:31, "Anthony Jones" <> wrote:
    >
    >
    >
    >
    >
    > > <> wrote in message

    >
    > >news:...

    >
    > > > 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, """", "&quot;",1,-1,1)
    > > > TempStr = Replace(TempStr, "'", "&rsquo;",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, """", "&quot;")
    > >         rQuote = Replace(rQuote , "'", "&apos;")
    > >     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 &apos;

    >
    > > --
    > > Anthony Jones - MVP ASP/ASP.NET-הסתר טקסט מצוטט-

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

    >
    > 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
    , Jan 22, 2008
    #8
  9. 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
    > %>
    > <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.


    --
    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.
    Bob Barrows [MVP], Jan 22, 2008
    #9
  10. Guest

    On 22 ינו×ר, 20:20, "Bob Barrows [MVP]" <>
    wrote:
    > 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
    > > %>
    > > <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.
    >
    > --
    > 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
    , Jan 22, 2008
    #10
  11. Jeff Dillon Guest

    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:...
    On 22 ?????, 20:20, "Bob Barrows [MVP]" <>
    wrote:
    > 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
    > > %>
    > > <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.
    >
    > --
    > 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
    Jeff Dillon, Jan 22, 2008
    #11
  12. 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.
    Bob Barrows [MVP], Jan 22, 2008
    #12
  13. Guest

    On 22 ינו×ר, 21:20, "Bob Barrows [MVP]" <>
    wrote:
    > 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 "<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
    , Jan 22, 2008
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J Rieggle
    Replies:
    1
    Views:
    460
    Curt_C [MVP]
    Jul 21, 2005
  2. Elhanan
    Replies:
    1
    Views:
    394
    Elhanan
    May 1, 2006
  3. Gilles Ganault

    [2.5.1] Str.Replace() doesn't work?

    Gilles Ganault, Dec 26, 2008, in forum: Python
    Replies:
    1
    Views:
    267
    Gilles Ganault
    Dec 26, 2008
  4. Cameron
    Replies:
    1
    Views:
    108
    Ken Schaefer
    Sep 4, 2003
  5. francisco lopez
    Replies:
    2
    Views:
    264
    Hywel Jenkins
    Dec 30, 2004
Loading...

Share This Page