Results 1 to 3 of 3

Thread: Please look at my code!

  1. #1

    Thread Starter
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281
    I'm sure it's just a dumb mistake but I cannot see it (hmm..what does that make me then?!)

    Anyway, I'm making a guestbook app that uses a text file, not a database.

    My first form is called addentry.htm - It has 4 fields : Name, Email, URL and Comment. It then Posts to an ASP page called Submit. asp. This is where I am getting the following error:

    Microsoft VBScript runtime (0x800A003E)
    Input past end of file

    Here is the code for Submit.ASP:

    Code:
    <% 
    
    Option Explicit 
    Const ForReading = 1, ForWriting = 2, ForAppending = 8 
    
      Dim objFS, objFile, entries, textstream
      Dim name, email,url, comment, signed
    
    'read guestbook entries into textstream
      Set objFS = Server.CreateObject ("Scripting.FileSystemObject")
      set objFile = objFS.GetFile(server.mappath("entries.dat"))
      set textstream = objFile.OpenAsTextStream(ForReading, -2)
      entries = textstream.ReadAll
      textstream.close
    
    'read data entered into form
      name = Request.Form("name")
      email = Request.Form("email")
      url = Request.Form("url")
      comment = Request.Form("comment")
     signed = FormatDateTime(Date, 1) & " " & Time
    
    objFile.WriteLine("<font face=Verdana size=2>" & comment & "<p>")
    
      'print name if entered
      if Not(name = "") then objFile.WriteLine(name & "<br> ")
    
      'print URL if entered
      if Not(url = "") then objFile.WriteLine(url & "<Br> ")
    
      'print email if entered
      if Not(email = "") then objFile.WriteLine(email & "<Br> ")
    
      'print date signed
      objFile.WriteLine("- " & signed & "</font>")
      
      
    
      objFile.WriteLine(entries)
    'close file
      objFile.close
      response.redirect ("guestbook.asp") 
      %>
    Is the error becuase I'm trying to add a date/time field?
    Thanks,

    CG

  2. #2

    Thread Starter
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281

    Unhappy

    Anybody? Please?

  3. #3
    New Member
    Join Date
    Feb 2001
    Posts
    12
    Lo there,

    Not sure if this will help or not, just looked like you were using a odd way of finding and opening the files etc.

    following may work, havent tested it just edited the code u typed.

    Code:
    <%
    Option Explicit 
    Const ForReading = 1, ForWriting = 2, ForAppending = 8 
    
      Dim objFS, objFile, entries, textstream
      Dim name, email,url, comment, signed
    
    'read guestbook entries into textstream
      Set objFS = Server.CreateObject("Scripting.FileSystemObject")
      objFile = Server.MapPath("entries.dat")
      Set textstream = objFS.OpenTextFile(objFile, ForReading)
      entries = textstream.ReadAll
      textstream.Close
      Set textstream = Nothing
    
    'read data entered into form
      name = Request.Form("name")
      email = Request.Form("email")
      url = Request.Form("url")
      comment = Request.Form("comment")
     signed = FormatDateTime(Date, 1) & " " & Time
    
      Set textstream = objFS.CreateTextFile(objFile, 1)
      textstream.WriteLine("<font face=Verdana size=2>" & comment & "<p>")
    
      'print name if entered
      if Not(name = "") then textstream.WriteLine(name & "<br> ")
    
      'print URL if entered
      if Not(url = "") then textstream.WriteLine(url & "<Br> ")
    
      'print email if entered
      if Not(email = "") then textstream.WriteLine(email & "<Br> ")
    
      'print date signed
      textstream.WriteLine("- " & signed & "</font>")
      textstream.Write(entries)
      textstream.Close
      Set textstream = Nothing
      Set objFS = Nothing
    
      response.redirect ("guestbook.asp") 
    %>

Posting Permissions

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



Click Here to Expand Forum to Full Width