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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE QUERY WON'TWORK

Status
Not open for further replies.

ashw

MIS
Jun 10, 2002
61
CA
I have developed a webpage weblinks.cfm which shows the weblinks added by the users fron another page NewWeblink.cfm. On weblinks.cfm page the name of the weblink is a link which when clicked goes to the ViewEditWeblink.cfm. Here we can edit the data and click submit to go to EditWeblinksubmit.cfm page.
I have written the following code

ViewEditWeblink.cfm Code
<!---CF Query View Edit selected Weblink --->
<CFQUERY NAME=&quot;Web&quot; DATASOURCE=&quot;weblink&quot;>
SELECT *
FROM Tblweblink
WHERE weblinkID = #URL.weblinkID#
</CFQUERY>

<!---CF Includes Site.css contains header and menu--->
<cfinclude template=&quot;/Newhome/site.css&quot;>
<script language=&quot;JavaScript&quot;>
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+&quot;.location='&quot;+args[i+1]+&quot;'&quot;);
}
//-->
</script>


<div ID=&quot;Center&quot;>
<html>
<head>
<title>View Edit Weblinks</title>
<!---CF Query Department database--->
<cfquery name=&quot;departmentsearch&quot; datasource=&quot;staffdirectory&quot;>
SELECT deptID, dept
FROM tbldepartment
</cfquery>
</head>

<!---CF Form Action (submits to Editweblinksubmit.cfm)--->
<cfform action=&quot;Editweblinksubmit.cfm&quot; name=&quot;vieweditweblink&quot;
method=&quot;POST&quot; enctype=&quot;multipart/form-data&quot; onsubmit=&quot;return validate(vieweditweblink)&quot;>
<body>
<table>
<th colspan=&quot;2&quot;>View Edit Web Link</th>
<tr>
<td>Site Name</td>
<td>
<!--- View and Edit existing Information --->
<cfoutput query=&quot;web&quot;>
<input type=&quot;hidden&quot; name=&quot;weblinkID&quot; value=&quot;#weblinkID#&quot;>

<cfinput type=&quot;text&quot; name=&quot;weblinkName&quot; value=&quot;#weblinkName#&quot;
MESSAGE=&quot;Website Name is required!&quot; REQUIRED=&quot;Yes&quot;>
</td>
</tr>
<tr>
<td>Site Address</td>
<td>
<cfinput type=&quot;text&quot; name=&quot;weblinkaddress&quot; value=&quot;#weblinkaddress#&quot;
MESSAGE=&quot;Website Address is required!&quot; REQUIRED=&quot;Yes&quot;>i.e. </td>
</tr>
<tr>
<td>Department</td>
<td>
<cfselect name=&quot;weblinkdepartment&quot; value=&quot;#weblinkdescription#&quot;
MESSAGE=&quot;Department is required!&quot; REQUIRED=&quot;yes&quot;>
<!---CF Department Search Output--->
<option value=&quot;&quot;>#weblinkdepartment#</option>
<cfloop query=&quot;departmentsearch&quot;>
<option value=&quot;#dept#&quot;>#dept#</option>
</cfloop>
</cfselect>
</td>
</tr>
<tr>
<td>Description</td>
<td>
<textarea name=&quot;weblinkdescription&quot; rows=&quot;6&quot; cols=&quot;60&quot;>&quot;#weblinkdescription#&quot;</textarea>

</td>
</tr>
<tr>
<td>Author</td>
<td>
<cfinput type=&quot;text&quot; name=&quot;weblinkauthor&quot; value=&quot;#weblinkauthor#&quot;
MESSAGE=&quot;Author Field is required!&quot; REQUIRED=&quot;Yes&quot;>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
<input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Reset&quot;>
<input type=&quot;button&quot; name=&quot;Button&quot; value=&quot;Cancel&quot; onClick=&quot;MM_goToURL('parent','Weblinks.cfm');return document.MM_returnValue&quot;>

</td>
</tr>
</table>
</body>
</cfoutput>
</cfform>
</div>
</html>

Editweblinksubmit.cfm Code
<html>
<head>
<title>Untitled</title>
</head>

<body>
<!---CF Query To Update Weblink in TblWeblink --->
<cfquery datasource=&quot;weblink&quot; dbtype=&quot;ODBC&quot;>
Update tblweblink
SET weblinkName='#Trim(FORM.weblinkname)#',
weblinkAddress='#Trim(FORM.weblinkaddress)#',
weblinkDescription='#Trim(FORM.weblinkdescription)#',
weblinkDepartment='#Trim(FORM.weblinkdepartment)#',
weblinkAuthor='#Trim(FORM.weblinkauthor)#',
WHERE weblinkID=#FORM.weblinkID#
</cfquery>
<CFLOCATION url=&quot;weblink.cfm&quot;>
</body>
</html>
 
you didn't say what the problem was, so i'll guess ;-)

in ViewEditWeblink.cfm, you have cfform outside the body, in fact you have quite a number of html tags in the wrong order

in Editweblinksubmit.cfm, you don't actually need any html tags, and you have a comma in front of the WHRE keyword that will cause an sql syntax error

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top