|
Okay, I am hacking a sciprt that works like a guestbook system, but is really just a tag board. Now I am having a problem sending the information off too the database, I keep on getting the following error
---------------------------------------------------- Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. /wolfsweb/shouts.app.asp, line 125 ----------------------------------------------------
Here is the scirpt it happenes on (minus the HTML header and footer)...
---------------------------------------------------- <% Flag = request.form("Flag") If IsEmpty(Flag) or Flag = "" then %> <form action="/wolfsweb/shouts.app.asp" method="post"> <p> <input type="text" name="Message" maxlength="120" size="23" class="box" onfocus="if(this.value=='message')this.value=''; this.style.background='#006060';" onblur="if(this.value=='')this.value='message'; this.style.background='#007575';" rows="1" cols="20" value="message"><br> <input type="text" name="URL" maxlength="120" size="23" value="website" class="box" onfocus="if(this.value=='website')this.value='http://'; this.style.background='#006060';" onblur="if(this.value=='http://')this.value='website'; this.style.background='#007575';"><br> <input type="text" name="Name" maxlength="20" size="14" value="name" class="box" onfocus="if(this.value=='name')this.value=''; this.style.background='#006060';" onblur="if(this.value=='')this.value='name'; this.style.background='#007575';"> <input class="tonOff" onMouseOver="hoverTon(this);" onMouseOut="offTon(this);" type="submit" value=" post " name="submit"></p> <input type="hidden" name="Flag" value=1> </form>
<% End If If Flag = 1 then If IsEmpty(request.form("Name")) or request.form("Name")="name" or request.form("Name")=" " then response.write "<p class=""center"">" response.write "You must enter a name.<form>" response.write "<br>" response.write "<input class=""tonOff"" onMouseOver=""hoverTon(this);"" onMouseOut=""offTon(this);"" type=""button"" value=""Retry"" onclick=""history.back()"">" response.write "</form></p>" response.end Else Name = request.form("Name") End If
If request.form("URL")="website" or request.form("URL")=" " then URL = "" Else URL = request.form("URL") End If If IsEmpty(request.form("Message")) or request.form("Message")="message" or request.form("Message")=" " then response.write "<p class=""center"">" response.write "Don't forget to enter your comments!<form>" response.write "<br>" response.write "<input class=""tonOff"" onMouseOver=""hoverTon(this);"" onMouseOut=""offTon(this);"" type=""button"" value=""Retry"" onclick=""history.back()"">" response.write "</form></p>" response.end Else Comments = request.form("Message") Comments = Replace(Message, Chr(34), "''") Comments = Replace(Message, vbCrLf, "<br>") End If Flag = request.form("Flag")
%>
<form action="/wolfsweb/shouts.app.asp" method="post"><p class="center"><small>"<%= Message %>"</small><br> <input type="hidden" name="Message" value="<%= Message %>"> <input type="hidden" name="URL" value="<%= URL %>"> <input type="hidden" name="Name" value="<%= Name %>"> <input class="tonOff" onMouseOver="hoverTon(this);" onMouseOut="offTon(this);" type="submit" value="submit, <%= Name %>?"></p> <input type="hidden" name="Flag" value=2></form>
<% End If If Flag = 2 then Today = Now() Comments = request.form("Message") Comments = Replace(Message, "'", "''") URL = request.form("URL") Name = request.form("Name") Name = Replace(Name, "'", "''") Name = Replace(Name, Chr(34), "''")
' ok now we've got our data so let's ship it off to the database set conn = server.createobject("adodb.connection") DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("/wolfsweb/db/wolfweb.mdb") conn.Open DSNtemp SQLstmt = "INSERT INTO Shout (Message,URL,Name)" SQLstmt = SQLstmt & " VALUES (" SQLstmt = SQLstmt & "'" & Message & "'," SQLstmt = SQLstmt & "'" & URL & "'," SQLstmt = SQLstmt & "'" & Name & "'," SQLstmt = SQLstmt & ")" Set RS = conn.execute(SQLstmt) If err.number>0 then response.write "VBScript Errors Occured:" & "<P>" response.write "Error Number=" & err.number & "<P>" response.write "Error Descr.=" & err.description & "<P>" response.write "Help Context=" & err.helpcontext & "<P>" response.write "Help Path=" & err.helppath & "<P>" response.write "Native Error=" & err.nativeerror & "<P>" response.write "Source=" & err.source & "<P>" response.write "SQLState=" & err.sqlstate & "<P>" end if IF conn.errors.count> 0 then response.write "Database Errors Occured" & "<P>" response.write SQLstmt & "<P>" for counter= 0 to conn.errors.count response.write "Error #" & conn.errors(counter).number & "<P>" response.write "Error desc. -> " & conn.errors(counter).description & "<P>" next else response.write "<p class=""center"">Submitted</p>" end if Conn.Close Set conn = nothing End If %> ----------------------------------------------------
Now, I can't for the life of me figure out where it's gone wrong and it's doing my head in. I spent 3 hours last night just looking around the code to figure out where it's gone wrong. I'll give the orginal from where I am hacking it from to help...
---------------------------------------------------- <% Flag = request.form("Flag") If IsEmpty(Flag) or Flag = "" then %> <font face="times new roman"> <i><h1>Sign My Guestbook</h1></i> <font face="arial" size=2> <b><i>Note:</i> * indicates a required field</b><
------------- Wolfie--[ http://www.wolfweb.co.uk - WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
|