By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,506 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,506 IT Pros & Developers. It's quick & easy.

ASP - unexpected error

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

thanks in advance

here is my code can anyone see anything wrong with this?
Expand|Select|Wrap|Line Numbers
  1.  <% 
  2. response.buffer = true
  3.  
  4. date = Replace(Server.HTMLEncode(Request.Form("date")),"'","''")
  5. event = Replace(Server.HTMLEncode(Request.Form("event")),"'","''")
  6. venue = Replace(Server.HTMLEncode(Request.Form("venue")),"'","''")
  7. details = Request.Form("details")
  8. details = Replace(details , "'", "''")
  9. details = Replace(details, vbcrlf, "<br>")
  10.  
  11. if date = "" OR event = "" OR venue = "" OR details = "" then
  12. Response.Redirect("post.asp?error=1")
  13. end if
  14. if instr(LCase(details), "<script") <> 0 then 
  15. Response.Redirect("post.asp?error=2")
  16. end if
  17.  
  18. set conn = Server.CreateObject("ADODB.connection")
  19. sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
  20. "Data Source=" & Server.MapPath("\upcoming Events\db\upcoming.mdb") & ";" & _ 
  21. "Persist Security Info=False" 
  22. conn.Open(sConnection) 
  23.  
  24. sqlstring = "INSERT INTO board ( date, event, venue, details ) " &_ 
  25. "values ('" & date & "','" & event & "','" & venue & "','" & details & "')" 
  26. conn.Execute(sqlstring)
  27. conn.Close 
  28. set conn = Nothing
  29. Response.redirect "\upcoming events\defualt.asp"
  30. %>
  31.  
Apr 19 '08 #1
Share this Question
Share on Google+
2 Replies


P: 92
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 "IsNullOrEmpty" for that...
Apr 21 '08 #2

P: 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 "IsNullOrEmpty" for that...
Thanks for the help is working now silly mistake take care
Apr 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.