Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in UPDATE statement..

Status
Not open for further replies.

iteach2

Technical User
Sep 16, 2001
120
US
Howdy!

I am very new to ASP but have been playing with PHP. I have a form that I wish to use to update one record in the database over and over again. My database is called tblContent in it are fields id and content. The form looks like this:


<form method=&quot;post&quot; action=&quot;addtomarquee.asp&quot;>

<textarea rows=&quot;8&quot; name=&quot;datainfo&quot;</textarea></td>

<input type=&quot;submit&quot; value=&quot;Submit!&quot;>>

<input type=&quot;hidden&quot; name=&quot;secret&quot; value=&quot;1&quot;>
</form>

-----------------

The SQL page looks like this:

<%@Language=VBScript%>
<% Option Explicit %>


<%
Dim conn
Dim SQL

set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.ConnectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & server.mappath(&quot;essex.mdb&quot;)
conn.open


SQL = &quot;Update tblContent SET content WHERE id = '&quot;&Request.Form(&quot;secret&quot;)&&quot;' AND content = '&quot;&Request.Form(&quot;datainfo&quot;)&&quot;'&quot;

conn.Execute SQL
conn.Close
Set conn = Nothing
%>

What am I doing wrong??



 
The following should do it, I replaced the ' with '' oterwise when somone fills out a ' character in the textarea the sql statement will fail again.

SQL = &quot;Update tblContent SET content = = '&quot; & replace(Request.Form(&quot;datainfo&quot;),&quot;'&quot;,&quot;''&quot;) & &quot;' WHERE id = &quot;&Request.Form(&quot;secret&quot;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top