ASP - unexpected error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ryan0026
    New Member
    • Apr 2008
    • 2

    ASP - unexpected error

    Hi im having a proble with this code, please can someone help it says unexpected error on line 5, event = Replace(Server. HTMLEncode(Requ est.Form("event ")),"'","'' ")

    thanks in advance

    here is my code can anyone see anything wrong with this?
    Code:
     <% 
    response.buffer = true
     
    date = Replace(Server.HTMLEncode(Request.Form("date")),"'","''")
    event = Replace(Server.HTMLEncode(Request.Form("event")),"'","''")
    venue = Replace(Server.HTMLEncode(Request.Form("venue")),"'","''")
    details = Request.Form("details")
    details = Replace(details , "'", "''")
    details = Replace(details, vbcrlf, "<br>")
     
    if date = "" OR event = "" OR venue = "" OR details = "" then
    Response.Redirect("post.asp?error=1")
    end if
    if instr(LCase(details), "<script") <> 0 then 
    Response.Redirect("post.asp?error=2")
    end if
     
    set conn = Server.CreateObject("ADODB.connection")
    sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
    "Data Source=" & Server.MapPath("\upcoming Events\db\upcoming.mdb") & ";" & _ 
    "Persist Security Info=False" 
    conn.Open(sConnection) 
     
    sqlstring = "INSERT INTO board ( date, event, venue, details ) " &_ 
    "values ('" & date & "','" & event & "','" & venue & "','" & details & "')" 
    conn.Execute(sqlstring)
    conn.Close 
    set conn = Nothing
    Response.redirect "\upcoming events\defualt.asp"
    %>
    Last edited by DrBunchman; Apr 21 '08, 08:11 AM. Reason: Added code tags - note the # button
  • deric
    New Member
    • Dec 2007
    • 92

    #2
    Request.Form("" ) might have returned a Null or nothing value. Replace function will return an error if the string in the first argument is a null/nothing.
    If it is possible that Request to a form will return nothing (eg, "event" doesn't exists in your form), it is good that you check the returned value first.
    You may use "Is Nothing" or "IsNullOrEm pty" for that...

    Comment

    • ryan0026
      New Member
      • Apr 2008
      • 2

      #3
      Originally posted by deric
      Request.Form("" ) might have returned a Null or nothing value. Replace function will return an error if the string in the first argument is a null/nothing.
      If it is possible that Request to a form will return nothing (eg, "event" doesn't exists in your form), it is good that you check the returned value first.
      You may use "Is Nothing" or "IsNullOrEm pty" for that...
      Thanks for the help is working now silly mistake take care

      Comment

      Working...