Click to See Complete Forum and Search --> : incorrect syntax


chrismartz
06-13-2005, 09:29 AM
Does anyone see why the URL portion of this code would output an error of Microsoft OLE DB Provider for SQL Server error '80040e14'

Line 1: Incorrect syntax near 'asdf'.

notshowinglocation.asp, line 42
when I would type asdf?
<%
Dim blogtitle,dateposted,timeposted,strSQL,author,i,j,url,strlink
blogtitle = request.form("title")
message = Replace(message, chr(39), "'")
message = Replace(message, chr(34), "&quot;")
message = Replace(message, vbCrLf, "<br /><br />")
message = Replace(message, "", "<strong >")
message = Replace(message, "", "</strong >")
message = Replace(message, "", "<em>")
message = Replace(message, "", "</em>")
message = Replace(message, "", "<un>")
message = Replace(message, "", "</un>")
message = Replace(message, "", "&quot;")
message = Replace(message, "", "&quot;")
While instr(message, "[URI=") > 0
i = instr(message, "[URI=")
j = instr(i, message, "]")
strLink = mid(message, i, j-i)
url = split(strLink, "=")(1)

message = replace(message, strLink & "]", "<a href='" & url & "' title='" & url & "'>")
message = replace(message, "[/URL]", "</a>")
Wend
author = Session("username")
dateposted = date
timeposted = time

strSQL="INSERT INTO blog(blog_message,blog_title,date_posted,time_posted,author)"
strSQL=strSQL & " VALUES('" & message & "','" & blogtitle & "','" & dateposted & "','" & timeposted & "','" & author & "')"
objDC.execute(strSQL)

phpnovice
06-13-2005, 10:46 AM
Since the message is from the SQL engine, this sounds like a single-quote type of error. Thus, your values need massaging:

...
" VALUES('" & Replace(message, "'", "''") & "','" & _
Replace(blogtitle, "'", "''") & "','" & _
dateposted & "','" & timeposted & "','" & _
Replace(author, "'", "''") & "')"
...

chrismartz
06-13-2005, 11:13 AM
I don't have any ' in what I am trying to post though

phpnovice
06-13-2005, 11:34 AM
Can't tell anything else from that scrambled stuff in your post. Can you fix that? You can edit your original post.

chrismartz
06-13-2005, 11:42 AM
There, how is that?

phpnovice
06-13-2005, 11:59 AM
Better. Now, what is it you're trying to accomplish and where are you typing that URL?

chrismartz
06-15-2005, 01:04 PM
Got this figured out.

phpnovice
06-15-2005, 01:08 PM
Cheers.