Forum Moderators: open

Message Too Old, No Replies

ASP form page not updating record details

         

galahad2

9:53 am on Oct 15, 2009 (gmt 0)

10+ Year Member



I have inherited an ASP site which unfortunately isn't working as it should- for instance I have this record editing page, which brings up the record details but just isn't updating the database- as if the Submit effectively ignores any changes made in the inputs.

I've done some digging around (unfortunately a load of detective work trying to figure out what happened previously with this site). It's a long file, so I'll put the head and body in 2 separate posts. BTW I've tested and checked the actual db connection string and that's all fine.

Head section as follows:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#include file="../Connections/allaston.asp" -->
<!-- #INCLUDE file="../fckeditor/fckeditor.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_update")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_allaston_STRING
MM_editCmd.CommandText = "UPDATE allaston.cars SET is_live = ?, first_set_live_on = ?, is_archived = ?, archived_on = ?, Sold = ?, Order_no = ?, title = ?, Price = ?, Variant = ?, Chassis_no = ?, Make = ?, Engine_no = ?, Model_type = ?, Full_registration = ?, First_registration = ?, Year_of_car = ?, Colour = ?, Doors = ?, Interior = ?, Four_wheel_drive = ?, Hood = ?, Mileage = ?, Mileage_warranty = ?, Engine_size = ?, Steering = ?, Fuel_type = ?, Comments = ?, Options = ?, car_description = ?, MOT_history = ?, Service_history_details = ?, sold_on = ? WHERE ID = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 65535, Request.Form("is_livexx")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(Request.Form("live_on"), Request.Form("live_on"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 201, 1, 65535, Request.Form("is_archivedxx")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 135, 1, -1, MM_IIF(Request.Form("archived_on"), Request.Form("archived_on"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 201, 1, 65535, Request.Form("soldxx")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("Order_no"), Request.Form("Order_no"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 201, 1, 65535, Request.Form("title")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 5, 1, -1, MM_IIF(Request.Form("price"), Request.Form("price"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 201, 1, 16777215, Request.Form("variant")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 201, 1, 65535, Request.Form("Chassis_no")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 201, 1, 65535, Request.Form("make")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 201, 1, 65535, Request.Form("Engine_no")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 201, 1, 65535, Request.Form("model_type")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 201, 1, 65535, Request.Form("Full_registration")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 201, 1, 65535, Request.Form("First_registration")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 201, 1, 65535, Request.Form("Year_of_car")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 201, 1, 65535, Request.Form("Colour")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param18", 201, 1, 255, Request.Form("Doors")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param19", 201, 1, 65535, Request.Form("Interior")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param20", 201, 1, 255, Request.Form("Four_wheel_drive")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param21", 201, 1, 65535, Request.Form("Hood")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param22", 201, 1, 65535, Request.Form("Mileage")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param23", 201, 1, 65535, Request.Form("select")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param24", 201, 1, 255, Request.Form("Engine_size")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param25", 201, 1, 65535, Request.Form("steering")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param26", 201, 1, 255, Request.Form("Transmission")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param27", 201, 1, -1, Request.Form("comments")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param28", 201, 1, -1, Request.Form("options")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param29", 201, 1, -1, Request.Form("car_description")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param30", 201, 1, -1, Request.Form("mot_history")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param31", 201, 1, -1, Request.Form("service_history_details")) ' adLongVarChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param33", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param32", 201, 1, -1, Request.Form("sold_on")) ' adLongVarChar

dim lRecs
MM_editCmd.Execute lRecs,,128

Response.Write lRecs & " records were affected by this query"
response.write(MM_editCmd.parameters("param33").Value)

response.write "<!--"
For i = 0 To MM_editCmd.parameters.Count - 1 'Iterate through the array

Response.Write( MM_editCmd.parameters(i).Value & chr(13) )
Next
response.write "-->"
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "home.asp"
'If (Request.QueryString <> "") Then
' If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
' MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
' Else
' MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
' End If
'End If
'Response.Redirect(MM_editRedirectUrl)
'Response.Write("<script>window.open('home.asp','_self');</script>")

End If

End If
%>

<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("id") <> "") Then
Recordset1__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_allaston_STRING
Recordset1_cmd.CommandText = "SELECT * FROM allaston.cars WHERE id = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 5, 1, -1, Recordset1__MMColParam) ' adDouble

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "546"
If (Request.Querystring("carid") <> "") Then
Recordset2__MMColParam = Request.Querystring("carid")
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_allaston_STRING
Recordset2.Source = "SELECT * FROM allaston.pictures WHERE car_id = " + Replace(Recordset2__MMColParam, "'", "''") + " ORDER BY pic_position ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
<%
Dim Recordset3
Dim Recordset3_cmd
Dim Recordset3_numRows

Set Recordset3_cmd = Server.CreateObject ("ADODB.Command")
Recordset3_cmd.ActiveConnection = MM_allaston_STRING
Recordset3_cmd.CommandText = "SELECT DISTINCT Model_type FROM allaston.cars ORDER BY Model_type"
Recordset3_cmd.Prepared = true

Set Recordset3 = Recordset3_cmd.Execute
Recordset3_numRows = 0
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit car details</title>
<link href="../css/ALLASTON.css" rel="stylesheet" type="text/css" />
</head>

galahad2

10:03 am on Oct 15, 2009 (gmt 0)

10+ Year Member



BODY section:


<body>
<center>
<link href="../css/ALLASTON.css" rel="stylesheet" type="text/css">
<form action="<%=MM_editAction%>" name="form1" method="POST">

<!--#include file="navigation.asp"-->
<div id="banner"></div>
<!-- end banner -->
<div id="mainpage">
<!-- mainpage -->
<% counter=0
while (Not Recordset2.EOF)
counter=counter +1
Recordset2.MoveNext()
Wend

if Not Recordset2.EOF then
Recordset2.MoveFirst()

Dim picid
reDIM picid(counter,2)
i=1
while (Not Recordset2.EOF)
picid(i,1)=(Recordset2.Fields.Item("id").Value)
picid(i,2)=(Recordset2.Fields.Item("pic_position").Value)
i=i+1
Recordset2.MoveNext()
Wend
Recordset2.MoveFirst()
end if
%>

<div id="textbox">
<!-- picturebox -->
<table width="901">
<tr>
<td width="420" bgcolor="#333333" class="bodycopy12"><div align="center">Edit Car infomation carid=<%=Request.Querystring("carid")%></div></td>
<td width="248" height="19" bgcolor="#3366FF" class="bodycopyboldwt">Non Viewing Information:</td>
<td width="217" height="19" bgcolor="#3366FF" class="bodycopy"></td>
</tr>
<tr>
<td width="420" rowspan="3" bgcolor="#333333" class="bodycopy12">
<%carid=Request.Querystring("carid")%><!--#include file="show6_pics.asp"--></td>
<script type="text/JavaScript">
<!--

function setarchdate(setto2,thisform) { //v1.0
var now = new Date();
var mydate = now.format("isoDate");
if (setto2 == "Y" )
{
thisform.archived_on.value=mydate;
}
else
{
thisform.archived_on.value="";
}
}
function setlivedate(setto,thisform) { //v1.0
var now = new Date();
var mydate = now.format("isoDate");
if (setto == "Y" )
{
thisform.live_on.value=mydate;
}
else
{
thisform.live_on.value="";
}
}
function setsolddate(setto3,thisform) { //v1.0
var now = new Date();
var mydate = now.format("isoDate");
if (setto3 == "yes" )
{
thisform.sold_on.value=mydate;
}
else
{
thisform.sold_on.value="";
}
}
//-->
</script>
<td height="19" bgcolor="#3366FF" class="bodycopy"><div align="right">Is Live:</div></td>
<td height="19" bgcolor="#3366FF" class="bodycopy">
<%' onBlur="setlivedate(form.is_livexx.value,this.form)" %>
<%' get value
islive=(Recordset1.Fields.Item("is_live").Value)%>
<select name="is_livexx" class="8ptbodycopy" onBlur="setlivedate(form.is_livexx.value,this.form)" >
<%if islive="Y" then%>
<option value="Y" selected="selected" >YES</option>
<option value="N" >NO</option>
<%else%>
<option value="Y" selected="selected" >YES</option>
<option value="N" selected="selected" >NO</option>
<%end if%>
</select>
<% ' set time in hidden field %>
<input type="hidden" name="live_on" size="19" value="<%=(Recordset1.Fields.Item("first_set_live_on").Value)%>" /></td>
</tr>
<tr>
<td height="19" bgcolor="#3366FF" class="bodycopy"><div align="right">Is Archived:</div></td>
<td height="19" bgcolor="#3366FF" class="bodycopy">
<%' onBlur="setarchdate(form.is_archivedxx.value,this.form)" %>
<%' get value
isarchived=(Recordset1.Fields.Item("is_archived").Value)%>
<select name="is_archivedxx" class="8ptbodycopy" onBlur="setarchdate(form.is_archivedxx.value,this.form)">
<%if isarchived="Y" then%>
<option value="Y" selected="selected" >YES</option>
<option value="N" >NO</option>
<%else%>
<option value="Y" selected="selected" >YES</option>
<option value="N" selected="selected" >NO</option>
<%end if%>
</select>
<input type="hidden" name="archived_on" size="19" value="<%=(Recordset1.Fields.Item("archived_on").Value)%>" /></td>
</tr>
<tr>
<td height="19" bgcolor="#3366FF" class="bodycopy"><div align="right">Sold:</div></td>
<td height="19" bgcolor="#3366FF" class="bodycopy">
<select name="soldxx" class="8ptbodycopy" onblur="setsolddate(form.soldxx.value,this.form)">
<%' get value
sold=(Recordset1.Fields.Item("Sold").Value)%>
<%if sold="yes" then%>
<option value="yes" selected="selected" >YES</option>
<option value="no" >NO</option>
<%else%>
<option value="yes" selected="selected" >YES</option>
<option value="no" selected="selected" >NO</option>
<%end if%>
</select>
<input type="hidden" name="sold_on" size="19" value="<%=(Recordset1.Fields.Item("sold_on").Value)%>" /> </td>
</tr>
<tr>
<td width="420" valign="middle" bgcolor="#333333" class="bodycopy12"><div align="center">
<input name="add_photos" type="button" value="add photos" / OnClick="window.open('add_photos.asp?carid=<%=request.Querystring("carid")%>&id=<%=request.Querystring("id")%>','_self')">
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <input name="add_photos" type="button" value="preview photos" / OnClick="window.open('quick_preview.asp?carid=<%=request.Querystring("carid")%>','_self')">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
<input name="reorder_photos2" type="button" value="reorder photos" / OnClick="window.open('reorder_photos.asp?id=<%=request.Querystring("id")%>&carid=<%=request.Querystring("carid")%>','_self')" />
</div></td>
<td height="19" bgcolor="#3366FF" class="bodycopyboldwt"><div align="right"><span class="bodycopy">Order in database: </span></div></td>
<td height="19" bgcolor="#3366FF" class="bodycopy"><span class="bodycopyboldwt">
<input type="text" name="Order_no" size="12" value="<%=(Recordset1.Fields.Item("Order_no").Value)%>"/>
</span>
<%model_ty=(Recordset1.Fields.Item("Model_type").Value)%>
<input name="button2" type="button" value="Preview others"
onclick="window.open('show_order.asp?model=<%=model_ty%>','_blank','scrollbars=1,width=650')"/></td>
</tr>
</table>
<table width="901" border="0" cellspacing="2" cellpadding="2" bgcolor="#000000">
<tr bgcolor="#333333">
<td colspan="2"><input type="text" name="title" value="<%=(Recordset1.Fields.Item("title").Value)%>" size="35"/>
<span class="bodycopy">Title</span> </td>
<td width="179"><div align="right"><span class="bodycopy">price</span>
<input type="text" name="price" value="<%=(Recordset1.Fields.Item("price").Value)%>" size="8" onmouseover="Tip(txt1), ABOVE, true, CENTERMOUSE, true"/>
</div></td>
<td width="25">&nbsp;</td>
<td width="465" rowspan="2"><span class="bodycopyboldwt"><span class="bodycopy"><a href="#" onmouseover="Tip(txt2), ABOVE, true, CENTERMOUSE, true" class="bodycopy">comments </a></span><br />
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "../fckeditor/"
oFCKeditor.ToolbarSet = "Basicplus"
oFCKeditor.Value = (Recordset1.Fields.Item("Comments").Value)
oFCKeditor.Height = "84"
oFCKeditor.Create "comments"
%>
</span></td>
</tr>
<tr bgcolor="#333333">
<td colspan="2"><input type="text" name="variant" value="<%=(Recordset1.Fields.Item("variant").Value)%>" size="35"/>
<span class="bodycopy">Variant</span></td>
<td class="8ptbodycopy"></td>
<td class="8ptbodycopy">&nbsp;</td>
</tr>
</table>
<table width="900">
<%' comments only after id 1094 ? %>
<tr>
<td colspan="5" bgcolor="#333333" class="bodycopyboldwt"><div align="center">
<input name="submit2" type="submit" value="Click to Update information" />
</div></td>
</tr>
<tr>
<td colspan="5" bgcolor="#333333" class="bodycopyboldwt">&nbsp;</td>
</tr>
<tr>
<td width="156" height="19" bgcolor="#333333" class="bodycopyboldwt">Chassis Number: </td>
<td width="233" height="19" bgcolor="#333333" class="bodycopy"><input type="text" name="Chassis_no" value="<%=(Recordset1.Fields.Item("Chassis_no").Value)%>" size="26" class="bodycopybgd"/></td>
<td width="39" bgcolor="#333333" class="bodycopy">&nbsp;</td>
<td width="144" bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">Make:</span></td>
<td bgcolor="#333333" class="bodycopy"><select id="make" name="make" >
<option value="AlfaRomeo" <%If (Not isNull((Recordset1.Fields.Item("Make").Value))) Then If ("AlfaRomeo" = ((Recordset1.Fields.Item("Make").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Alfa Romeo</option>
<option value="AstonMartin" selected="selected" <%If (Not isNull((Recordset1.Fields.Item("Make").Value))) Then If ("AstonMartin" = ((Recordset1.Fields.Item("Make").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Aston Martin</option>
<option value="Audi" <%If (Not isNull((Recordset1.Fields.Item("Make").Value))) Then If ("Audi" = ((Recordset1.Fields.Item("Make").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Audi</option>
<option value="Bentley" <%If (Not isNull((Recordset1.Fields.Item("Make").Value))) Then If ("Bentley" = ((Recordset1.Fields.Item("Make").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Bentley</option>

</select></td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">EngineNumber:</td>
<td height="19" bgcolor="#333333" class="bodycopy"><input type="text" name="Engine_no" value="<%=(Recordset1.Fields.Item("Engine_no").Value)%>" size="26" class="bodycopybgd"/> </td>
<td bgcolor="#333333" class="bodycopy">&nbsp;</td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">Model Type</span></td>
<td bgcolor="#333333" class="bodycopy">
<select name="select2" id="model_type2" onblur="(form.model_type.value) = (form.model_type2.value)">
<option value="0">Select or type in new below</option>
<%
While (NOT Recordset3.EOF)
%>
<%text=(Recordset3.Fields.Item("Model_type").Value)%>
<option value="<%=text%>"><%=text%></option>
<%
Recordset3.MoveNext()
Wend
If (Recordset3.CursorType > 0) Then
Recordset3.MoveFirst
Else
Recordset3.Requery
End If
%>
</select>
<input type="text" name="model_type" value="<%=(Recordset1.Fields.Item("Model_type").Value)%>" size="29" /> </td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">UK Registration Number:</td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><input type="text" name="Full_registration" value="<%=(Recordset1.Fields.Item("Full_registration").Value)%>" size="26" class="bodycopybgd"/> </td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">Body Type:</span></td>
<td width="304" bgcolor="#333333" class="bodycopy"><select name="Body_type">
<option value="Saloon" <%If (Not isNull((Recordset1.Fields.Item("Body_type").Value))) Then If ("Saloon" = CStr((Recordset1.Fields.Item("Body_type").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Saloon</option>
</select></td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Date of first reg:</td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><input type="text" name="First_registration" value="<%=(Recordset1.Fields.Item("First_registration").Value)%>" size="26" class="bodycopybgd"/> </td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">Year of car:</span></td>
<td bgcolor="#333333" class="bodycopy"><input type="text" name="Year_of_car" value="<%=(Recordset1.Fields.Item("Year_of_car").Value)%>" size="14" class="bodycopybgd"/></td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Exterior colour:</td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><input type="text" name="Colour" value="<%=(Recordset1.Fields.Item("Colour").Value)%>" size="26" class="bodycopybgd"/></td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">No of Doors:</span></td>
<td bgcolor="#333333" class="bodycopy"><select name="Doors" class="bodycopybgd">
<option value="1" <%If (Not isNull((Recordset1.Fields.Item("Doors").Value))) Then If ("1" = CStr((Recordset1.Fields.Item("Doors").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>1</option>
<option value="2" <%If (Not isNull((Recordset1.Fields.Item("Doors").Value))) Then If ("2" = CStr((Recordset1.Fields.Item("Doors").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>2</option>

</select></td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Interior colour: </td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><input type="text" name="Interior" value="<%=(Recordset1.Fields.Item("Interior").Value)%>" size="26" class="bodycopybgd"/></td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">4 Wheel Drive:</span></td>
<td bgcolor="#333333" class="bodycopy"><select name="Four_wheel_drive" class="bodycopybgd">
<option value="Y" <%If (Not isNull((Recordset1.Fields.Item("Four_wheel_drive").Value))) Then If ("Y" = CStr((Recordset1.Fields.Item("Four_wheel_drive").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>YES</option>
<option value="N" selected="selected" <%If (Not isNull((Recordset1.Fields.Item("Four_wheel_drive").Value))) Then If ("N" = CStr((Recordset1.Fields.Item("Four_wheel_drive").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>NO</option>
</select></td>
</tr>
<%if len(Recordset1.Fields.Item("Hood").Value)>0 then%>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Hood: </td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><input type="text" name="Hood" value="<%=(Recordset1.Fields.Item("Hood").Value)%>" size="26" class="bodycopybgd"/></td>
<td bgcolor="#333333" class="bodycopy">&nbsp;</td>
<td bgcolor="#333333" class="bodycopy">&nbsp;</td>
</tr>
<%end if%>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Current Odometer reading: </td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><input type="text" name="Mileage" value="<%=(Recordset1.Fields.Item("Mileage").Value)%>" size="8" class="bodycopybgd"/>
<select name="select" class="bodycopybgd">
<option value="miles (Not Warranted)." <%If (Not isNull((Recordset1.Fields.Item("Mileage_warranty").Value))) Then If ("miles (Not Warranted)." = ((Recordset1.Fields.Item("Mileage_warranty").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>miles (Not Warranted).</option>
<option value="miles." <%If (Not isNull((Recordset1.Fields.Item("Mileage_warranty").Value))) Then If ("miles." = ((Recordset1.Fields.Item("Mileage_warranty").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>miles.</option>
</select> </td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">Engine size (in litres):</span></td>
<td bgcolor="#333333" class="bodycopy"><input type="text" name="Engine_size" value="<%=(Recordset1.Fields.Item("Engine_size").Value)%>" size="12" class="bodycopybgd"/></td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Steering:</td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><% steer=(Recordset1.Fields.Item("Steering").Value) %>
<select name="steering">
<option value="Left" <%If (Not isNull(steer)) Then If ("Left" = (steer)) Then Response.Write("selected=""selected""") : Response.Write("")%>>Left</option>
<option value="Right" <%If (Not isNull(steer)) Then If ("Right" = (steer)) Then Response.Write("selected=""selected""") : Response.Write("")%>>Right</option>
</select></td>
<td bgcolor="#333333" class="bodycopy"><span class="bodycopyboldwt">Fuel Type:</span></td>
<td bgcolor="#333333" class="bodycopy"><select name="Fuel_type" class="bodycopybgd">
<option value="Petrol" selected="selected" <%If (Not isNull((Recordset1.Fields.Item("Fuel_type").Value))) Then If ("Petrol" = CStr((Recordset1.Fields.Item("Fuel_type").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Petrol</option>
<option value="Diesel" <%If (Not isNull((Recordset1.Fields.Item("Fuel_type").Value))) Then If ("Diesel" = CStr((Recordset1.Fields.Item("Fuel_type").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Diesel</option>
</select></td>
</tr>
<tr>
<td height="19" bgcolor="#333333" class="bodycopyboldwt">Transmission:</td>
<td height="19" colspan="2" bgcolor="#333333" class="bodycopy"><%trans=(Recordset1.Fields.Item("Transmission").Value)%>
<select name="Transmission">
<option value="Manual" <%If (Not isNull((Recordset1.Fields.Item("Transmission").Value))) Then If ("Manual" = ((Recordset1.Fields.Item("Transmission").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Manual</option>
<option value="Automatic" <%If (Not isNull((Recordset1.Fields.Item("Transmission").Value))) Then If ("Automatic" = ((Recordset1.Fields.Item("Transmission").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Automatic</option>

</select></td>
<td bgcolor="#333333" class="bodycopy">&nbsp;</td>
<td bgcolor="#333333" class="bodycopy">&nbsp;</td>
</tr>
<tr>
<td height="19" colspan="5" bgcolor="#333333" class="bodycopyboldwt">Options:
<%
Dim oFCKeditor5
Set oFCKeditor5 = New FCKeditor
oFCKeditor5.BasePath = "../fckeditor/"
oFCKeditor5.ToolbarSet = "Basicplus"
oFCKeditor5.Value = (Recordset1.Fields.Item("Options").Value)
oFCKeditor5.Height = "94"
oFCKeditor5.Create "options"
%> </td>
</tr>
<tr>
<td height="19" colspan="5" bgcolor="#333333" class="bodycopyboldwt"> Description
<%
Dim oFCKeditor2
Set oFCKeditor2 = New FCKeditor
oFCKeditor2.BasePath = "../fckeditor/"
oFCKeditor2.ToolbarSet = "Medium"
oFCKeditor2.Value = (Recordset1.Fields.Item("car_description").Value)
oFCKeditor2.Height = "400"
oFCKeditor2.Create "car_description"
%></td>
</tr>
<tr>
<td height="19" colspan="5" bgcolor="#333333" class="bodycopyboldwt">Mot History
<%
Dim oFCKeditor3
Set oFCKeditor3 = New FCKeditor
oFCKeditor3.BasePath = "../fckeditor/"
oFCKeditor3.ToolbarSet = "Medium"
oFCKeditor3.Value = (Recordset1.Fields.Item("Mot_History").Value)
oFCKeditor3.Height = "300"
oFCKeditor3.Create "mot_history"
%></td>
</tr>
<tr>
<td height="19" colspan="5" bgcolor="#333333" class="bodycopyboldwt">Service history details
<%
Dim oFCKeditor4
Set oFCKeditor4 = New FCKeditor
oFCKeditor4.BasePath = "../fckeditor/"
oFCKeditor4.ToolbarSet = "Medium"
oFCKeditor4.Value = (Recordset1.Fields.Item("Service_history_details").Value)
oFCKeditor4.Height = "300"
oFCKeditor4.Create "Service_history_details"
%></td>
</tr>
<tr>
<td height="19" colspan="5" bgcolor="#333333" class="bodycopyboldwt"><div align="center">
<input name="submit" type="submit" value="Click to Update" />
</div></td>
</tr>
</table>
<br />
</div>
</div>

<!--<input name="comments" type=hidden>
<input name="options" type=hidden>
<input name="car_description" type=hidden>
<input name="mot_history" type=hidden>
<input name="service_history_details" type=hidden>
-->
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("ID").Value %>" />
</p>
</form>

<!-- mainpage -->
</div>
<!-- end wrap -->

</center>
</body>
</html><%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%

Recordset2.Close()
Set Recordset2 = Nothing
%>
<%
Recordset3.Close()
Set Recordset3 = Nothing
%>

(I took out some of the OPTION elements as there were so many it took the code over the chcracter limit- obviously these aren't critical)

Ocean10000

1:48 pm on Oct 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I can not tell if this is an MS SQL DB. But if it is have you tried to use "SQL Server Profiler" to watch the sql commands being run as they happen? What this will tell you is if the actual edit and update happen. Just looking over the code I do not see any problem jumping out why it is not saving.

galahad2

2:01 pm on Oct 15, 2009 (gmt 0)

10+ Year Member



Hi, it's actually connecting to a MySQL database.

galahad2

11:34 am on Oct 16, 2009 (gmt 0)

10+ Year Member



I also added a few Response.Write lines at the top of the head area (someone recommended it for troubleshooting), as follows:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#include file="../Connections/allaston.asp" -->
<!-- #INCLUDE file="../fckeditor/fckeditor.asp" -->
<%
Dim MM_editAction

Response.Write("MM_Update value: " & Request("MM_update") & "<br />")
Response.Write("MM_recordId value: " & Request("MM_recordId") & "<br />")

But they don't output anything in the browser when I browse to the file on the server after changing and uploading. Any ideas?

swa66

11:26 pm on Oct 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It might be that your MySQL instance / the interface between your ASP and MySQL doesn't support the prepared statement.

Such support might be as simple as a compile time option in MySQL (upgraded recently/moved servers or something like that?)

galahad2

9:12 am on Oct 20, 2009 (gmt 0)

10+ Year Member



Hi, no the site has been on the same server for a while now.

I've done some further digging around, looking at the file "stock_admin.asp" which is referenced in the file I posted (stock_details_edit.asp): I don't know if the file sheds any clues...

<!--#include file="../Connections/allaston.asp" -->

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_allaston_STRING
Recordset1.Source = "SELECT * FROM allaston.cars WHERE is_archived='N' AND is_live='Y' ORDER BY Year_of_car ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Function Getpic(carno)
Dim Recordset2__MMColParam
Recordset2__MMColParam = carno

Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_allaston_STRING
Recordset2.Source = "SELECT * FROM allaston.pictures WHERE car_id = " + Replace(Recordset2__MMColParam, "'", "''") + " ORDER BY pic_position ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
if not Recordset2.EOF then
Getpic = (Recordset2.Fields.Item("pic_filename").Value)
end if
Recordset2.Close()
Set Recordset2 = Nothing
end function
%>
<%
Dim HLooper1__numRows
HLooper1__numRows = -3
Dim HLooper1__index
HLooper1__index = 0
Recordset1_numRows = Recordset1_numRows + HLooper1__numRows
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<link href="../css/ALLASTON.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../scripts/mootools.js"></script>
<script type="text/javascript" src="../scripts/reflection.js"></script>
<body>
<script type="text/javascript" src="../scripts/wz_tooltip.js"></script>


<table width="620" border="0">

<tr>
<td class="bodycopyboldwt" width=207><div align="center">
<table>

<%
startrw = 0
endrw = HLooper1__index
numberColumns = 3
numrows = -1
while((numrows <> 0) AND (Not Recordset1.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>
<tr align="center" valign="top" class="bodycopyboldwt">
<%
While ((startrw <= endrw) AND (Not Recordset1.EOF))
%>
<% 'check to see if pic exists
picreq = getpic((Recordset1.Fields.Item("carid").Value))
picrequired="small_" & Replace(picreq,"_orig","")
if request.servervariables("SERVER_NAME")="ians64" then
dirrequ = "J:\inetpub64\wwwroot\allastonmartin\pictures\" & picrequired
else
dirrequ = "\\iis699\domains\a\allastonmartin.co.uk\user\htdocs\pictures\" & picrequired
end if
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'If (fs.FileExists(dirrequ)=true) Then
'picrequired = picreq
'Else
'picrequired = "blank.jpg"
'End If %>
<%car_title = (Recordset1.Fields.Item("title").Value)%>
<td width="306" ><%=car_title%><br>&pound;<%=(Recordset1.Fields.Item("Price").Value)%><br>

<% if len(car_title)=<32 then %>
<br>
<%end if%>
<img src="../images/spacer.gif" width="200" height="1"/>
<% ' add alternate link for stock edit 24/03

urlreq="car_details_edit.asp"

%>
<a href="<%=urlreq%>?id=<%=(Recordset1.Fields.Item("id").Value)%>&carid=<%=(Recordset1.Fields.Item("carid").Value)%>" target="_top" >
<img src="../pictures/<%=picrequired%>" width="200" height="133" border="0" usemap="#Map<%=startrw%>" class="reflect" onMouseOver="Tip('<b><%=(Recordset1.Fields.Item("title").Value)%><br>&pound;<%=(Recordset1.Fields.Item("Price").Value)%></b><br><%=(Recordset1.Fields.Item("Chassis_no").Value)%><br /><%=(Recordset1.Fields.Item("Transmission").Value)%>&nbsp;&nbsp;<%=(Recordset1.Fields.Item("Year_of_car").Value)%>&nbsp;&nbsp;<%=(Recordset1.Fields.Item("Steering").Value)%> hd<br />Colour: <%=(Recordset1.Fields.Item("Colour").Value)%><br />Interior: <%=(Recordset1.Fields.Item("Interior").Value)%><br />Hood: <%=(Recordset1.Fields.Item("Hood").Value)%>', TITLE ,'Click photo for full details', WIDTH, 180, SHADOW, true, FADEIN, 300, FADEOUT, 300, OFFSETY, 40)";car_for_sale.asp?carid=<%=(Recordset1.Fields.Item("carid").Value)%>","_top")/></a></td>
<%' example Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 %>
<%' MSIE ie = 26 Firefox=77 %>

<% broswer=(INStr(Request.ServerVariables("HTTP_USER_AGENT"),"MSIE")) %>
<% if broswer>0 then
' if IE add picture map as reflect disaples the link%>
<map name="Map<%=startrw%>">
<area shape="rect" coords="4,5,194,132" href="<%=urlreq%>?id=<%=(Recordset1.Fields.Item("id").Value)%>&carid=<%=(Recordset1.Fields.Item("carid").Value)%>" target="_top" >
</map>
<%end if%>
<%
startrw = startrw + 1
Recordset1.MoveNext()
Wend
%>
</tr>
<%
numrows=numrows-1
Wend
%>
</table>
</div></td>

</tr>
<tr><td class="bodycopy12">Looking for a particular model ?<br>
If you are looking for a specific vehicle - please let us know and I will contact you with any information or sellers I may have. <a href="../car_wanted.asp" class="bodycopy12" target="_parent">Click here</a> to find out more.</td>

</table>

</body>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>

Interestingly though I'm now getting values passed when I go from stock_list_edit.asp, click a car to edit, and then get to car_details_edit.asp, with all the car details having been brought from the db.


MM_Update value: form1<br />MM_recordId value: 1120<br />0 records were affected by this query1120