Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Posts
    3

    Question Unanswered: Apostrophe Problem

    I am a complete ASP newbie and I have to modify/fix someone else's code, so please be very detailed when answering, i.e. where to place the code.

    History:
    > 1. I have code that when used in a file it dynamically pulls information
    > from a text database (database.txt). It is strictly a text file.
    >
    > 2. The file(s) with the dynamic code also does some image morphing.
    >
    >
    Problem:
    > In the database.txt file there is the name O'Brien. The images will not
    > morph unless I remove the apostrophe from O'Brien.
    >
    > This is part of the code in the database.txt file:
    > Jane OBrien
    > obrien.asp
    > Instructional Designer II
    > o
    > Instructional Design and New Business
    >
    >
    > This is the code in the non database file:
    > 'create second counter
    > counter2 = 0
    >
    > 'change the line below if the name of this group changes
    > ID = "Instructional Design and New Business"
    > %>
    >
    > <script language="JavaScript1.1">
    > <!--
    > <%
    > 'create the fso object
    >
    > set fso = Server.Createobject("Scripting.FileSystemObject")
    >
    > 'create file path to database
    >
    > abspath = server.mappath(Session("VirtualBasePath")) &
    > "\about_sdu\whos_who\"
    > path = abspath & "database.txt"
    >
    > 'open the file
    >
    > set file = fso.opentextfile(path, 1)
    >
    > 'create counter
    >
    > counter = 1
    >
    > 'search through database
    >
    > do until file.AtEndOfStream
    >
    > name = file.ReadLine
    > bio = file.ReadLine
    > title = file.ReadLine
    > alpha = file.ReadLine
    > group = file.ReadLine
    > file.ReadLine
    >
    > strG = group
    > if trim(group) = ID then
    > response.write "var image" & counter & "=new
    > Image();" & chr(10) & chr(13) & "image" & counter &
    > ".src='../../images/about_sdu/associates/" & name & ".jpg';" & chr(10) &
    > chr(13)
    > counter = counter + 1
    > end if
    > do while instr(strG, "/")
    > splitGroup = Left(strG, instr(strG, "/") - 1)
    > if trim(splitGroup) = ID then
    > response.write "var image" & counter & "=new
    > Image();" & chr(10) & chr(13) & "image" & counter &
    > ".src='../../images/about_sdu/associates/" & name & ".jpg';" & chr(10) &
    > chr(13)
    > counter = counter + 1
    > end if
    > strG = Right(strG, len(strG) - instr(strG, "/"))
    > if strG <> splitGroup then
    > if trim(strG) = ID then
    > response.write "var image" & counter
    > & "=new Image();" & chr(10) & chr(13) & "image" & counter &
    > ".src='../../images/about_sdu/associates/" & name & ".jpg';" & chr(10) &
    > chr(13)
    > counter = counter + 1
    > end if
    > end if
    > loop
    >
    > loop
    >
    > ' close and clean up
    >
    > file.close
    > set file = nothing
    > set fso = nothing
    > %>
    >
    >
    > //-->
    > </script>
    > <script language="JavaScript1.2">
    > function reapply(){
    > setTimeout("slideit()",3000)
    > return true
    > }
    > window.onerror=reapply
    > </script>
    > <script>
    > <!--
    > //change speed below (in seconds)
    > var speed=3
    > var random
    > var destHREF
    > Link=new Array()
    > <%
    > 'create the fso object
    >
    > set fso2 = Server.Createobject("Scripting.FileSystemObject")
    >
    > 'create file path to database
    >
    > abspath2 = server.mappath(Session("VirtualBasePath")) &
    > "\about_sdu\whos_who\"
    > path2 = abspath2 & "database.txt"
    >
    > 'open the file
    >
    > set file2 = fso2.opentextfile(path2, 1)
    >
    > 'create counter
    >
    > counter2 = 0
    >
    > 'search through database
    >
    > do until file2.AtEndOfStream
    >
    > name = file2.ReadLine
    > bio = file2.ReadLine
    > title = file2.ReadLine
    > alpha = file2.ReadLine
    > group = file2.ReadLine
    > file2.ReadLine
    >
    > strG = group
    > if trim(group) = ID then
    > response.write "Link[" & counter2 & "]='associates/"
    > & trim(bio) & "';" & chr(10) & chr(11)
    > counter2 = counter2 + 1
    > end if
    > do while instr(strG, "/")
    > splitGroup = Left(strG, instr(strG, "/") - 1)
    > if trim(splitGroup) = ID then
    > response.write "Link[" & counter2 &
    > "]='associates/" & trim(bio) & "';" & chr(10) & chr(11)
    > counter2 = counter2 + 1
    > end if
    > strG = Right(strG, len(strG) - instr(strG, "/"))
    > if strG <> splitGroup then
    > if trim(strG) = ID then
    > response.write "Link[" & counter2 &
    > "]='associates/" & trim(bio) & "';" & chr(10) & chr(11)
    > counter2 = counter2 + 1
    > end if
    > end if
    > loop
    >
    >
    > loop
    >
    > ' close and clean up
    >
    > file2.close
    > set file2 = nothing
    > set fso2 = nothing
    > %>
    >
    > //-->
    > </script>

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Why is the apostrophe giving you a problem ? Is it being imported into a database ?

  3. #3
    Join Date
    Nov 2002
    Posts
    3
    Yes it is...

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    Which database ? Try the replace function with vbscript and replace ' (single quote) with '' (2 single quotes). That should fix your problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •