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

Uploading 3 images instead of 1

Status
Not open for further replies.

leeboycymru

Programmer
Jan 23, 2007
185
GB
I built a system before that could easily handle uploading 1 image via an admin page.

Now im building another and this time i wont to be able to upload 3 images at this time and maybe more if needs be.

Im using the code below in the form:

tr valign="bottom">
<td height="21" colspan="3"><strong>Picture of Full Length Clock:</strong></td>
</tr>
<tr>
<td height="21" colspan="3"><input type="file" name="artPicFull" id="artThumbPic3"
size="50"></td>
</tr>
<tr valign="bottom">
<td height="21" colspan="3"><strong>Picture of Hood of Clock:</strong></td>
</tr>
<tr>
<td height="21" colspan="3"><input type="file" name="artHood" id="artThumbPic3"
size="50"></td>
</tr>
<tr valign="bottom">
<td height="21" colspan="3"><strong>Picture of Face of Clock:</strong></td>
</tr>
<tr>
<td height="21" colspan="3"><input type="file" name="artFace" id="artThumbPic3"
size="50"></td>
</tr>

and the asp code is below:

Set Upload = Server.CreateObject("Persits.Upload")
theCount = upload.save(server.mappath("..")&"\images\uploaded")

For Each File in Upload.Files
filename = File.FileName
filename2 = File.FileName
filename3 = File.FileName

Next

'Count = Upload.SaveVirtual("../upload")

' Get the form variables
addProduct = TRIM (Upload.Form("addProduct"))
updateProduct = TRIM (Upload.Form("updateProduct"))
deleteProduct = TRIM (Upload.Form("deleteProduct"))

'response.write("delete=" & deleteProduct)

delID = TRIM (Upload.Form("delID"))
catID = TRIM (Upload.Form("catID"))
artTitle = TRIM (Upload.Form("artTitle"))
artCategory = TRIM (Upload.Form("artCategory"))
artBriefDesc = TRIM (Upload.Form("artBriefDesc"))
artPrice = TRIM (Upload.Form("artPrice"))
artPicFull = TRIM (filename)
artHood = TRIM (filename2)
artFace = TRIM (filename3)

Im not getting it to be honest, and could do with some help.

cheers

Lee
 
What is currently happening?? Are you still only able to upload one at a time with this code?


[monkey][snake] <.
 
No the three images upload, but it only offers the one image (the last one) for all three images.



 
I think your problem is here:
Code:
    For Each File in Upload.Files
    filename =  File.FileName
    filename2 =  File.FileName
    filename3 =  File.FileName
     
    Next

On each loop of Upload.Files you are storing the same filename in all 3 variables.

You need to store only the current File.FileName at a time.
Perhaps something like this (may not be syntactically correct):
Code:
    filename =  File.FileName(0)
    filename2 =  File.FileName(1)
    filename3 =  File.FileName(2)





[monkey][snake] <.
 
It sounds right what you are saying, i tired it and i got this error back:

Object not a collection: 'File.filename'

Lee
 
monksnake did indicate that his syntax may not necessarily be correct. :)

Your error message indicates that the object "File" is not a collection, which makes sense. What you may want to do is something similar to this (though there may be a better approach, this is just a quick hit thought on my part and is also not necessarily syntactically correct and therefore subject to further editing and testing on your part):
Code:
[COLOR=green]'This presumes that you will only ever have three values returned in your Upload.Files object.[/color]
dim arr(3), i
i = 1
For Each File in Upload.Files
  arr(i) =  File.FileName
  i = i + 1
Next 
[COLOR=green]'And now you can refer to them as arr(1), etc.[/color]

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
LOL

Thats what I love about this forum and the experts on it.

You always get "Oh try this bit of code, I doubt if it will work!!!" sort of attitude, and when you do it works first time no problems.

Thanks again

Lee
 
So problem is resolved?

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
ye thanks guys, I had an issue where when updating, it pulled it from the databse fine, but on editing and submitting i lost 2 of the images completely.

But I tracked it down and its all sorted now.

Thanks again

Lee
 
Good enough. Glad you got everything worked out. :)

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Hi Chopstick, seems as though I was duped by the information displayed and what was going to the database.

Adding those three images is no problem at all, thats great the code above worked a treat. But my propblem now lies when i try to edit that information and when I click submit again, only the top 3/4 entries go to the server whilst everything below although displayed as gone to the server, it doesnt actually go.

Below is the full page of code, I am using:

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


<% Server.ScriptTimeout = 360 %>
<%

' Get the Product ID
catID = Request( "pid" )
delID = Request( "pid" )

'initialise objects and variables
dim connU, strsqlU, rsuserU
'Set objCmd = Server.CreateObject("ADODB.Recordset")
set connU=server.createobject("ADODB.Connection")
set rsuserU=server.createobject("ADODB.Recordset")
strMDBpath = Server.MapPath("..\db_import\EventStyle.mdb")

'direct connection
connU.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & strMDBPath

rsuserU.ActiveConnection = connU
rsuserU.CursorType = 3
strsqlU = "SELECT * FROM eventDisplay WHERE cat_ID=" & catID

rsuserU.open strsqlU

IF NOT rsuserU.EOF THEN

artTitle = rsuserU( "art_Title" )
artCategory = rsuserU( "art_Category" )
artBriefDesc = rsuserU( "art_BDescription" )
artPrice = rsuserU( "art_Price" )
artPicFull = rsuserU( "art_ThumbFull" )
artHood = rsuserU( "art_ThumbHood" )
artFace = rsuserU( "art_ThumbFace" )
artCaseDesc = rsuserU( "case_Text" )
artDialDesc = rsuserU( "dial_Text" )
artMovementDesc = rsuserU( "movement_Text" )
artMakerDesc = rsuserU( "maker_Text" )
artDatDesc = rsuserU( "dat_Text" )
artHeightDesc = rsuserU( "height_Text" )
artStatus = rsuserU( "art_Status" )
artDisplay = rsuserU( "art_Display" )
artMoonDisplay = rsuserU( "art_MoonDisplay" )

END IF

rsuserU.Close

FUNCTION SELECTED( firstVal, secondVal )
IF cSTR( firstVal ) = cSTR( secondVal ) THEN
SELECTED = " SELECTED "
END IF
END FUNCTION

%>
<body bgcolor="White">
<form method="post" enctype="multipart/form-data" action="manageproducts_art.asp">
<center>
<table width="700" border="1" bgcolor="White" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" bgcolor="yellow"><b>
Edit or Update Clock Information: </b>
</td>
</tr>
<tr>
<td><b>Title:</b>
</td>
<td><input name="artTitle" size="50" maxlength="50" value="<%=Server.HTMLEncode( artTitle )%>">
</td>
</tr>
<tr>
<td><b>Category:</b>
</td>
<td> <select name="artCategory">
<option value="Longcase Mahogany" <%=SELECTED( "Longcase Mahogany", artCategory )%>>Longcase Mahogany
<option value="Longcase Oak" <%=SELECTED( "Longcase Oak", artCategory )%>>Longcase Oak
<option value="Longcase Walnut" <%=SELECTED( "Longcase Walnut", artCategory )%>>Longcase Walnut
<option value="Longcase Marquetry" <%=SELECTED( "Longcase Marquetry", artCategory )%>>Longcase Marquetry
<option value="Longcase Lacquer" <%=SELECTED( "Longcase Lacquer", artCategory )%>>Longcase Lacquer
<option value="Longcase Miscellaneous" <%=SELECTED( "Longcase Miscellaneous", artCategory )%>>Longcase Miscellaneous
<option value="Other clocks and instruments" <%=SELECTED( "Other clocks and instruments", artCategory )%>>Other clocks and instruments
<option value="Barometers" <%=SELECTED( "Barometers", artCategory )%>>Barometers
<option value="Longcase Mahogany Archive" <%=SELECTED( "Longcase Mahogany Archive", artCategory )%>>Longcase Mahogany Archive
<option value="Longcase Oak Archive" <%=SELECTED( "Longcase Oak Archive", artCategory )%>>Longcase Oak Archive
<option value="Longcase Walnut Archive" <%=SELECTED( "Longcase Walnut Archive", artCategory )%>>Longcase Walnut Archive
<option value="Longcase Marquetry Archive" <%=SELECTED( "Longcase Marquetry Archive", artCategory )%>>Longcase Marquetry Archive
<option value="Longcase Lacquer Archive" <%=SELECTED( "Longcase Lacquer Archive", artCategory )%>>Longcase Lacquer Archive
<option value="Longcase Miscellaneous Archive" <%=SELECTED( "Longcase Miscellaneous Archive", artCategory )%>>Longcase Miscellaneous Archive
<option value="Other clocks and instruments Archive" <%=SELECTED( "Other clocks and instruments Archive", artCategory )%>>Other clocks and instruments Archive
<option value="Barometers Archive" <%=SELECTED( "Barometers Archive", artCategory )%>>Barometers Archive
</select></td>
</tr>
<tr>
<tr>
<td><b>Brief Description:</b>
</td>
<td><textarea name="artBriefDesc" cols="50" rows="5"><%=Server.HTMLEncode( artBriefDesc )%></textarea>
</td>
</tr>
<tr>
<tr>
<td><b>Price:</b>
</td>
<td><input name="artPrice" size="50" maxlength="50" value="<%=Server.HTMLEncode( artPrice )%>">
</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Current Full Length Clock Picture:</b> </td>
<td bgcolor="#CCCCCC"><%=Server.HTMLEncode(artPicFull)%>&nbsp;</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>New Full Length Clock Picture:</b> </td>
<td bgcolor="#CCCCCC"><input name="artPicFull" size="50" type="file"></td>
</tr>
<tr>
<td><b>Current Clock Hood Picture:</b> </td>
<td><%=Server.HTMLEncode(artHood)%>&nbsp;</td>
</tr>
<tr>
<td><b>New Clock Hood Picture:</b> </td>
<td><input name="artHood" size="50" type="file"></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Current Clock Face Picture:</b> </td>
<td bgcolor="#CCCCCC"><%=Server.HTMLEncode(artFace)%>&nbsp;</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>New Clock Face Picture:</b> </td>
<td bgcolor="#CCCCCC"><input name="artFace" size="50" type="file"></td>
</tr>
<tr>
<td><b>Case Description:</b>
</td>
<td><textarea name="artCaseDesc" cols="50" rows="5"><%=Server.HTMLEncode( artCaseDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Dial Description:</b>
</td>
<td><textarea name="artDialDesc" cols="50" rows="5"><%=Server.HTMLEncode( artDialDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Movement Description:</b>
</td>
<td><textarea name="artMovementDesc" cols="50" rows="5"><%=Server.HTMLEncode( artMovementDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Maker Description:</b>
</td>
<td><textarea name="artMakerDesc" cols="50" rows="5"><%=Server.HTMLEncode( artMakerDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Date Description:</b>
</td>
<td><textarea name="artDatDesc" cols="50" rows="5"><%=Server.HTMLEncode( artDatDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Height Description:</b>
</td>
<td><textarea name="artHeightDesc" cols="50" rows="5"><%=Server.HTMLEncode( artHeightDesc )%></textarea>
</td>
</tr>
<tr>
<td><strong>Status:</strong></td>
<td><select name=artStatus id="select">
<option value="IN STOCK" <%=SELECTED( "IN STOCK", artStatus )%>>IN STOCK
<option value="SOLD" <%=SELECTED( "SOLD", artStatus )%>>SOLD
</select></td>
</tr>
<tr>
<td><strong>Display:</strong></td>
<td><select name=artDisplay id="select">
<option value="1" <%=SELECTED( "1", artDisplay )%>>YES
<option value="0" <%=SELECTED( "0", artDisplay )%>>NO
</select></td>
</tr>
<tr>
<td><strong>Moon Image Display:</strong></td>
<td><select name=artMoonDisplay id="select">
<option value="1" <%=SELECTED( "1", artMoonDisplay )%>>YES
<option value="0" <%=SELECTED( "0", artMoonDisplay )%>>NO
</select></td>
</tr>
<tr>

<tr>
<td><a href="../adminPage.asp">Back </a></td>
<td><div align="right">
<input type="hidden" name="origImage" value="<%=Server.HTMLEncode(artPicFull)%>" />
<input type="hidden" name="origHImage" value="<%=Server.HTMLEncode(artHood)%>" />
<input type="hidden" name="origFImage" value="<%=Server.HTMLEncode(artFace)%>" />
<input name="catID" type="hidden" value="<%=catID%>">
<input name="updateProduct" type="hidden" value="1">
<input name="submit" type="submit" value="Update Art">
</div></td>
</tr>
</table>
</center>
</form>
</body>
</html>
 
Sorry, but I'm not understanding your problem. What is the above code supposed to do that it is not doing? You say that it's "not going to the server" but I don't see anywhere in your above code where you're either inserting or updating data to the server so not sure what you're trying to do or what the problem might be.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Sorry ye i just realised what i had done...

It seems as though only the first 4 objects go to the database, whilst the others although indicate that they go to the databse, in fact they delete themselves.

Here is the page it goes too:

I got to be honest im lost now

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

<!-- #INCLUDE file="../checkpassword.asp" -->
<% Server.ScriptTimeout = 360 %>
<%

FUNCTION fixQuotes ( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION

set connM = server.createobject("ADODB.Connection")
connM.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("..\db_import\EventStyle.mdb")


if instr(Trim(Request.ServerVariables("HTTP_REFERER")),"addproduct_art.asp") or instr(Trim(Request.ServerVariables("HTTP_REFERER")),"updateproduct_art.asp") then


Set Upload = Server.CreateObject("Persits.Upload")
theCount = upload.save(server.mappath("..")&"\images\uploaded")

dim arr(3), i
i = 1
For Each File in Upload.Files
arr(i) = File.FileName
i = i + 1

'For Each File in Upload.Files
'filename = File.FileName(0)
'filename2 = File.FileName(1)
'filename3 = File.FileName(2)

Next

'Count = Upload.SaveVirtual("../upload")

' Get the form variables
addProduct = TRIM (Upload.Form("addProduct"))
updateProduct = TRIM (Upload.Form("updateProduct"))
deleteProduct = TRIM (Upload.Form("deleteProduct"))

'response.write("delete=" & deleteProduct)

delID = TRIM (Upload.Form("delID"))
catID = TRIM (Upload.Form("catID"))
artTitle = TRIM (Upload.Form("artTitle"))
artCategory = TRIM (Upload.Form("artCategory"))
artBriefDesc = TRIM (Upload.Form("artBriefDesc"))
artPrice = TRIM (Upload.Form("artPrice"))
artPicFull = TRIM (arr(1))
artHood = TRIM (arr(2))
artFace = TRIM (arr(3))
artCaseDesc = TRIM (Upload.Form("artCaseDesc"))
artDialDesc = TRIM (Upload.Form("artDialDesc"))
artMovementDesc = TRIM (Upload.Form("artMovementDesc"))
artMakerDesc = TRIM (Upload.Form("artMakerDesc"))
artDatDesc = TRIM (Upload.Form("artDatDesc"))
artHeightDesc = TRIM (Upload.Form("artHeightDesc"))
artMoonDisplay = TRIM (Upload.Form("artMoonDisplay"))
artStatus = TRIM (Upload.Form("artStatus"))
artDisplay = TRIM (Upload.Form("artDisplay"))
origImage = TRIM(upload.Form("origImage"))
origHImage = TRIM(upload.Form("origHImage"))
origFImage = TRIM(upload.Form("origFImage"))
set upload = nothing

'response.write("CATID=" & catID)

'Assign Default Values

IF artTitle = "" THEN
artTitle = "?????"
END IF
IF artCategory = "" THEN
artCategory = "?????"
END IF
IF artBriefDesc = "" THEN
artBriefDesc = "?????"
END IF
IF artPrice = "" THEN
artPrice = "?????"
END IF
IF artCaseDesc = "" THEN
artCaseDesc = "?????"
END IF
IF artDialDesc = "" THEN
artDialDesc = "?????"
END IF
IF artMovementDesc = "" THEN
artMovementDesc = "?????"
END IF
IF artMakerDesc = "" THEN
artMakerDesc = "?????"
END IF
IF artDatDesc = "" THEN
artDatDesc = "?????"
END IF
IF artHeightDesc = "" THEN
artHeightDesc = "?????"
END IF
IF artMoonDisplay = "" THEN
artMoonDisplay = "?????"
END IF
IF artStatus = "" THEN
artStatus = "?????"
END IF
IF artDisplay = "" THEN
artDisplay = "?????"
END IF
' Add new product

if artPicFull = "" then

Pimage = origImage

else

Pimage = artPicFull

end if

if artHood = "" then

Himage = origHImage

else

Himage = artHood

end if

if artFace = "" then

Fimage = origFImage

else

Fimage = artFace

end if

if addProduct <> "" then
strsqlM = "INSERT INTO eventDisplay " &_
"( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_ThumbHood, art_ThumbFace, case_Text, dial_Text, movement_Text, maker_Text, dat_Text, height_Text, art_Status, art_Display, art_MoonDisplay ) VALUES (" &_
" '" & fixQuotes (artTitle ) & "', " &_
" '" & fixQuotes (artCategory ) & "', " &_
" '" & fixQuotes (artBriefDesc ) & "', " &_
" '" & fixQuotes (artPrice ) & "', " &_
" '" & fixQuotes (artPicFull ) & "', " &_
" '" & fixQuotes (artHood ) & "', " &_
" '" & fixQuotes (artFace ) & "', " &_
" '" & fixQuotes (artCaseDesc ) & "', " &_
" '" & fixQuotes (artDialDesc ) & "', " &_
" '" & fixQuotes (artMovementDesc ) & "', " &_
" '" & fixQuotes (artMakerDesc ) & "', " &_
" '" & fixQuotes (artDatDesc ) & "', " &_
" '" & fixQuotes (artHeightDesc ) & "', " &_
" '" & fixQuotes (artStatus ) & "', " &_
" " & fixQuotes (artDisplay ) & ", " &_
" " & fixQuotes (artMoonDisplay ) & " )"

'rsuser.open strsql, conn
On Error Resume Next
ConnM.Execute strsqlM
If Err <> 0 Then
Response.Write "Error in query " & strsqlM
Response.End
End If

end if
%>
<style type="text/css">
<!--
.style2 {
color: #FF3400;
font-weight: bold;
}
-->
</style>
<center>
<br>
<table width="600" border="1" cellpadding="4"
cellspacing ="0" bgcolor="white">
<tr>
<td><strong>Clock Title:</strong></td>
<td><b><%=artTitle%></b> </td>
</tr>
<tr>
<td height="29"><strong>Category: </strong></td>
<td><b><%=artCategory%></b></td>
</tr>
<tr>
<td height="29"><strong>Brief Description:</strong></td>
<td><b><%=artBriefDesc%></b></td>
</tr>
<tr>
<td height="29"><strong>Price:</strong></td>
<td><b><%=artPrice%></b></td>
</tr>
<tr>
<td height="29"><strong>Picture of full length:</strong></td>
<td><b><%=Pimage%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Picture of the hood:</strong></td>
<td><b><%=Himage%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Picture of the face:</strong></td>
<td><b><%=Fimage%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Case Description:</strong></td>
<td><b><%=artCaseDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Dial Description:</strong></td>
<td><b><%=artDialDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Movement Description:</strong></td>
<td><b><%=artMovementDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Maker Description:</strong></td>
<td><b><%=artMakerDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Date Description:</strong></td>
<td><b><%=artDatDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Height Description:</strong></td>
<td><b><%=artHeightDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Status:</strong></td>
<td><br>
<b><%=artStatus%></b> </td>
</tr>
<tr>
<td height="29"><strong>Display:</strong></td>
<td><br>
<b><%=artDisplay%></b> </td>
</tr>
<tr>
<td height="29"><strong>Moon Display:</strong></td>
<td><b><%=artMoonDisplay%>&nbsp;</b></td>
</tr>
<tr>
<td height="29">&nbsp;</td>
<td><br/><span class="style2">Was added to the database</span> </td>
</tr>
</table>
</center>
<p>
<%


end if


%>

<%
' Update Product
IF updateProduct <> "" THEN

if artTitle = "" then

strsqlM = "UPDATE eventDisplay SET " &_
"art_Title='" & fixQuotes( artTitle ) & "', " &_
"art_Category='" & fixQuotes( artCategory ) & "', " &_
"art_BDescription='" & fixQuotes( artBriefDesc ) & "', " &_
"art_Price='" & fixQuotes( artPrice ) & "', " &_
"art_ThumbFull='" & fixQuotes( artPicFull ) & "', " &_
"art_ThumbHood='" & fixQuotes( artHood ) & "', " &_
"art_ThumbFace='" & fixQuotes( artFace ) & "', " &_
"case_Text='" & fixQuotes(artCaseText ) & "', " &_
"dial_Text='" & fixQuotes(artDialText ) & "', " &_
"movement_Text='" & fixQuotes(artMovementText ) & "', " &_
"maker_Text='" & fixQuotes(artMakerText ) & "', " &_
"dat_Text='" & fixQuotes(artDatText ) & "', " &_
"height_Text='" & fixQuotes(artHeightText ) & "', " &_
"art_Status='" & fixQuotes( artStatus ) & "', " &_
"art_Display=" & artDisplay & ", " &_
"art_MoonDisplay=" & artMoonDisplay & " " &_
" WHERE " &_
"cat_ID=" & catID


else

strsqlM = "UPDATE eventDisplay SET " &_
"art_Title='" & fixQuotes( artTitle ) & "', " &_
"art_Category='" & fixQuotes( artCategory ) & "', " &_
"art_BDescription='" & fixQuotes( artBriefDesc ) & "', " &_
"art_Price='" & fixQuotes(artPrice ) & "', " &_
"art_ThumbFull='" & fixQuotes( artPicFull ) & "', " &_
"art_ThumbHood='" & fixQuotes( artHood ) & "', " &_
"art_ThumbFace='" & fixQuotes( artFace ) & "', " &_
"case_Text='" & fixQuotes(artCaseText ) & "', " &_
"dial_Text='" & fixQuotes(artDialText ) & "', " &_
"movement_Text='" & fixQuotes(artMovementText ) & "', " &_
"maker_Text='" & fixQuotes(artMakerText ) & "', " &_
"dat_Text='" & fixQuotes(artDatText ) & "', " &_
"height_Text='" & fixQuotes(artHeightText ) & "', " &_
"art_Status='" & fixQuotes( artStatus ) & "', " &_
"art_Display=" & artDisplay & ", " &_
"art_MoonDisplay=" & artMoonDisplay & " " &_
" WHERE " &_
"cat_ID=" & catID

end if

ConnM.Execute strsqlM

%>

<center>
<table width="600" cellpadding="4"
cellspacing="0" >
<tr>
<td>
<%=artTitle%> was updated in the database
<br/>
<br/>
</td>
</tr>
</table>
</center>
<%
END IF
%>

<center>
<table width="600" border="1" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2"><strong>
Edit Clock Information - </strong>If you want to edit information of a specific clock use the section below to select the Clock Title:</td>
</tr>
<tr>
<td align="center">
<table border="1" size="400" cellpadding="3" cellspacing="0">
<%
strsqlM = "SELECT cat_ID, art_Title FROM eventDisplay " &_
"ORDER BY art_Title"

set rs = server.createobject("adodb.recordset")
rs.activeconnection = ConnM
rs.open strsqlM
WHILE NOT rs.EOF
%>

<tr>
<td>

<a href="updateproduct_art.asp?pid=<%=rs( "cat_ID")%>"><%=rs( "art_Title" )%></a>
</td>
</tr>
<% rs.MoveNext
WEND

rs.close
set rs = nothing

ConnM.close
set ConnM = nothing
%>
</table>
</td>
</tr>
<tr>
<td>
<a href="../adminPage.asp"> Back </a>
</td>
</tr>
</table>
</center>
 
I just thought of something, and that is Im going to check that everything is in the same order as the databse either when calling from the databse or updating,
 
Hi Chopstick,

Ok I went through every page and all is good now in terms of the ordering.

And as a result of tidying everything up all the data in the text fields and drop down are fine, but the last two images out of three do not get uploaded to the server, in fact it deletes what ever is in those 2 fields.

I will post each page for you to see:

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


<% Server.ScriptTimeout = 360 %>
<%

' Get the Product ID
catID = Request( "pid" )
delID = Request( "pid" )

'initialise objects and variables
dim connU, strsqlU, rsuserU
'Set objCmd = Server.CreateObject("ADODB.Recordset")
set connU=server.createobject("ADODB.Connection")
set rsuserU=server.createobject("ADODB.Recordset")
strMDBpath = Server.MapPath("..\db_import\EventStyle.mdb")

'direct connection
connU.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & strMDBPath

rsuserU.ActiveConnection = connU
rsuserU.CursorType = 3
strsqlU = "SELECT * FROM eventDisplay WHERE cat_ID=" & catID

rsuserU.open strsqlU

IF NOT rsuserU.EOF THEN

artTitle = rsuserU( "art_Title" )
artCategory = rsuserU( "art_Category" )
artBriefDesc = rsuserU( "art_BDescription" )
artPrice = rsuserU( "art_Price" )
artPicFull = rsuserU( "art_ThumbFull" )
artFace = rsuserU( "art_ThumbFace" )
artHood = rsuserU( "art_ThumbHood" )
artCaseDesc = rsuserU( "case_Text" )
artDialDesc = rsuserU( "dial_Text" )
artMovementDesc = rsuserU( "movement_Text" )
artMakerDesc = rsuserU( "maker_Text" )
artDatDesc = rsuserU( "dat_Text" )
artHeightDesc = rsuserU( "height_Text" )
artStatus = rsuserU( "art_Status" )
artDisplay = rsuserU( "art_Display" )
artMoonDisplay = rsuserU( "art_MoonDisplay" )

END IF

rsuserU.Close

FUNCTION SELECTED( firstVal, secondVal )
IF cSTR( firstVal ) = cSTR( secondVal ) THEN
SELECTED = " SELECTED "
END IF
END FUNCTION

%>
<body bgcolor="White">
<form method="post" enctype="multipart/form-data" action="manageproducts_art.asp">
<center>
<table width="700" border="1" bgcolor="White" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" bgcolor="yellow"><b>
Edit or Update Clock Information: </b>
</td>
</tr>
<tr>
<td><b>Title:</b>
</td>
<td><input name="artTitle" size="50" maxlength="50" value="<%=Server.HTMLEncode( artTitle )%>">
</td>
</tr>
<tr>
<td><b>Category:</b>
</td>
<td> <select name="artCategory">
<option value="Longcase Mahogany" <%=SELECTED( "Longcase Mahogany", artCategory )%>>Longcase Mahogany
<option value="Longcase Oak" <%=SELECTED( "Longcase Oak", artCategory )%>>Longcase Oak
<option value="Longcase Walnut" <%=SELECTED( "Longcase Walnut", artCategory )%>>Longcase Walnut
<option value="Longcase Marquetry" <%=SELECTED( "Longcase Marquetry", artCategory )%>>Longcase Marquetry
<option value="Longcase Lacquer" <%=SELECTED( "Longcase Lacquer", artCategory )%>>Longcase Lacquer
<option value="Longcase Miscellaneous" <%=SELECTED( "Longcase Miscellaneous", artCategory )%>>Longcase Miscellaneous
<option value="Other clocks and instruments" <%=SELECTED( "Other clocks and instruments", artCategory )%>>Other clocks and instruments
<option value="Barometers" <%=SELECTED( "Barometers", artCategory )%>>Barometers
<option value="Longcase Mahogany Archive" <%=SELECTED( "Longcase Mahogany Archive", artCategory )%>>Longcase Mahogany Archive
<option value="Longcase Oak Archive" <%=SELECTED( "Longcase Oak Archive", artCategory )%>>Longcase Oak Archive
<option value="Longcase Walnut Archive" <%=SELECTED( "Longcase Walnut Archive", artCategory )%>>Longcase Walnut Archive
<option value="Longcase Marquetry Archive" <%=SELECTED( "Longcase Marquetry Archive", artCategory )%>>Longcase Marquetry Archive
<option value="Longcase Lacquer Archive" <%=SELECTED( "Longcase Lacquer Archive", artCategory )%>>Longcase Lacquer Archive
<option value="Longcase Miscellaneous Archive" <%=SELECTED( "Longcase Miscellaneous Archive", artCategory )%>>Longcase Miscellaneous Archive
<option value="Other clocks and instruments Archive" <%=SELECTED( "Other clocks and instruments Archive", artCategory )%>>Other clocks and instruments Archive
<option value="Barometers Archive" <%=SELECTED( "Barometers Archive", artCategory )%>>Barometers Archive
</select></td>
</tr>
<tr>
<tr>
<td><b>Brief Description:</b>
</td>
<td><textarea name="artBriefDesc" cols="50" rows="5"><%=Server.HTMLEncode( artBriefDesc )%></textarea>
</td>
</tr>
<tr>
<tr>
<td><b>Price:</b>
</td>
<td><input name="artPrice" size="50" maxlength="50" value="<%=Server.HTMLEncode( artPrice )%>">
</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Current Full Length Clock Picture:</b> </td>
<td bgcolor="#CCCCCC"><%=Server.HTMLEncode(artPicFull)%>&nbsp;</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>New Full Length Clock Picture:</b> </td>
<td bgcolor="#CCCCCC"><input name="artPicFull" size="50" type="file"></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>Current Clock Face Picture:</b> </td>
<td bgcolor="#CCCCCC"><%=Server.HTMLEncode(artFace)%>&nbsp;</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><b>New Clock Face Picture:</b> </td>
<td bgcolor="#CCCCCC"><input name="artFace" size="50" type="file"></td>
</tr>
<tr>
<td><b>Current Clock Hood Picture:</b> </td>
<td><%=Server.HTMLEncode(artHood)%>&nbsp;</td>
</tr>
<tr>
<td><b>New Clock Hood Picture:</b> </td>
<td><input name="artHood" size="50" type="file"></td>
</tr>
<tr>
<td><b>Case Description:</b>
</td>
<td><textarea name="artCaseDesc" cols="50" rows="5"><%=Server.HTMLEncode( artCaseDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Dial Description:</b>
</td>
<td><textarea name="artDialDesc" cols="50" rows="5"><%=Server.HTMLEncode( artDialDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Movement Description:</b>
</td>
<td><textarea name="artMovementDesc" cols="50" rows="5"><%=Server.HTMLEncode( artMovementDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Maker Description:</b>
</td>
<td><textarea name="artMakerDesc" cols="50" rows="5"><%=Server.HTMLEncode( artMakerDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Date Description:</b>
</td>
<td><textarea name="artDatDesc" cols="50" rows="5"><%=Server.HTMLEncode( artDatDesc )%></textarea>
</td>
</tr>
<tr>
<td><b>Height Description:</b>
</td>
<td><textarea name="artHeightDesc" cols="50" rows="5"><%=Server.HTMLEncode( artHeightDesc )%></textarea>
</td>
</tr>
<tr>
<td><strong>Status:</strong></td>
<td><select name=artStatus id="select">
<option value="IN STOCK" <%=SELECTED( "IN STOCK", artStatus )%>>IN STOCK
<option value="SOLD" <%=SELECTED( "SOLD", artStatus )%>>SOLD
</select></td>
</tr>
<tr>
<td><strong>Display:</strong></td>
<td><select name=artDisplay id="select">
<option value="1" <%=SELECTED( "1", artDisplay )%>>YES
<option value="0" <%=SELECTED( "0", artDisplay )%>>NO
</select></td>
</tr>
<tr>
<td><strong>Moon Image Display:</strong></td>
<td><select name=artMoonDisplay id="select">
<option value="1" <%=SELECTED( "1", artMoonDisplay )%>>YES
<option value="0" <%=SELECTED( "0", artMoonDisplay )%>>NO
</select></td>
</tr>
<tr>

<tr>
<td><a href="../adminPage.asp">Back </a></td>
<td><div align="right">
<input type="hidden" name="origImage" value="<%=Server.HTMLEncode(artPicFull)%>" />
<input type="hidden" name="origFImage" value="<%=Server.HTMLEncode(artFace)%>" />
<input type="hidden" name="origHImage" value="<%=Server.HTMLEncode(artHood)%>" />
<input name="catID" type="hidden" value="<%=catID%>">
<input name="updateProduct" type="hidden" value="1">
<input name="submit" type="submit" value="Update Art">
</div></td>
</tr>
</table>
</center>
</form>
</body>
</html>

and this is the page that deals with the data:

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

<!-- #INCLUDE file="../checkpassword.asp" -->
<% Server.ScriptTimeout = 360 %>
<%

FUNCTION fixQuotes ( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION

set connM = server.createobject("ADODB.Connection")
connM.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("..\db_import\EventStyle.mdb")


if instr(Trim(Request.ServerVariables("HTTP_REFERER")),"addproduct_art.asp") or instr(Trim(Request.ServerVariables("HTTP_REFERER")),"updateproduct_art.asp") then


Set Upload = Server.CreateObject("Persits.Upload")
theCount = upload.save(server.mappath("..")&"\images\uploaded")

dim arr(3), i
i = 1
For Each File in Upload.Files
arr(i) = File.FileName
i = i + 1

Next

'Count = Upload.SaveVirtual("../upload")

' Get the form variables
addProduct = TRIM (Upload.Form("addProduct"))
updateProduct = TRIM (Upload.Form("updateProduct"))
deleteProduct = TRIM (Upload.Form("deleteProduct"))

'response.write("delete=" & deleteProduct)

delID = TRIM (Upload.Form("delID"))
catID = TRIM (Upload.Form("catID"))
artTitle = TRIM (Upload.Form("artTitle"))
artCategory = TRIM (Upload.Form("artCategory"))
artBriefDesc = TRIM (Upload.Form("artBriefDesc"))
artPrice = TRIM (Upload.Form("artPrice"))
artPicFull = TRIM (arr(1))
artFace = TRIM (arr(2))
artHood = TRIM (arr(3))
artCaseDesc = TRIM (Upload.Form("artCaseDesc"))
artDialDesc = TRIM (Upload.Form("artDialDesc"))
artMovementDesc = TRIM (Upload.Form("artMovementDesc"))
artMakerDesc = TRIM (Upload.Form("artMakerDesc"))
artDatDesc = TRIM (Upload.Form("artDatDesc"))
artHeightDesc = TRIM (Upload.Form("artHeightDesc"))
artStatus = TRIM (Upload.Form("artStatus"))
artMoonDisplay = TRIM (Upload.Form("artMoonDisplay"))
artDisplay = TRIM (Upload.Form("artDisplay"))
origImage = TRIM(upload.Form("origImage"))
origFImage = TRIM(upload.Form("origFImage"))
origHImage = TRIM(upload.Form("origHImage"))
set upload = nothing

'response.write("CATID=" & catID)

'Assign Default Values

IF artTitle = "" THEN
artTitle = "?????"
END IF
IF artCategory = "" THEN
artCategory = "?????"
END IF
IF artBriefDesc = "" THEN
artBriefDesc = "?????"
END IF
IF artPrice = "" THEN
artPrice = "?????"
END IF
IF artCaseDesc = "" THEN
artCaseDesc = "?????"
END IF
IF artDialDesc = "" THEN
artDialDesc = "?????"
END IF
IF artMovementDesc = "" THEN
artMovementDesc = "?????"
END IF
IF artMakerDesc = "" THEN
artMakerDesc = "?????"
END IF
IF artDatDesc = "" THEN
artDatDesc = "?????"
END IF
IF artHeightDesc = "" THEN
artHeightDesc = "?????"
END IF
IF artStatus = "" THEN
artStatus = "?????"
END IF
IF artMoonDisplay = "" THEN
artMoonDisplay = "?????"
END IF
IF artDisplay = "" THEN
artDisplay = "?????"
END IF
' Add new product

if artPicFull = "" then

Pimage = origImage

else

Pimage = artPicFull

end if

if artHood = "" then

Fimage = origFImage

else

Fimage = artFace

end if

if artFace = "" then

Himage = origHImage

else

Himage = artHood

end if

if addProduct <> "" then
strsqlM = "INSERT INTO eventDisplay " &_
"( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_ThumbFace, art_ThumbHood, case_Text, dial_Text, movement_Text, maker_Text, dat_Text, height_Text, art_Status, art_MoonDisplay, art_Display ) VALUES (" &_
" '" & fixQuotes (artTitle ) & "', " &_
" '" & fixQuotes (artCategory ) & "', " &_
" '" & fixQuotes (artBriefDesc ) & "', " &_
" '" & fixQuotes (artPrice ) & "', " &_
" '" & fixQuotes (artPicFull ) & "', " &_
" '" & fixQuotes (artFace ) & "', " &_
" '" & fixQuotes (artHood ) & "', " &_
" '" & fixQuotes (artCaseDesc ) & "', " &_
" '" & fixQuotes (artDialDesc ) & "', " &_
" '" & fixQuotes (artMovementDesc ) & "', " &_
" '" & fixQuotes (artMakerDesc ) & "', " &_
" '" & fixQuotes (artDatDesc ) & "', " &_
" '" & fixQuotes (artHeightDesc ) & "', " &_
" '" & fixQuotes (artStatus ) & "', " &_
" " & fixQuotes (artMoonDisplay ) & ", " &_
" " & fixQuotes (artDisplay ) & " )"

'rsuser.open strsql, conn
On Error Resume Next
ConnM.Execute strsqlM
If Err <> 0 Then
Response.Write "Error in query " & strsqlM
Response.End
End If

end if
%>
<style type="text/css">
<!--
.style2 {
color: #FF3400;
font-weight: bold;
}
-->
</style>
<center>
<br>
<table width="600" border="1" cellpadding="4"
cellspacing ="0" bgcolor="white">
<tr>
<td><strong>Clock Title:</strong></td>
<td><b><%=artTitle%></b> </td>
</tr>
<tr>
<td height="29"><strong>Category: </strong></td>
<td><b><%=artCategory%></b></td>
</tr>
<tr>
<td height="29"><strong>Brief Description:</strong></td>
<td><b><%=artBriefDesc%></b></td>
</tr>
<tr>
<td height="29"><strong>Price:</strong></td>
<td><b><%=artPrice%></b></td>
</tr>
<tr>
<td height="29"><strong>Picture of full length:</strong></td>
<td><b><%=Pimage%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Picture of the face:</strong></td>
<td><b><%=Fimage%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Picture of the hood:</strong></td>
<td><b><%=Himage%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Case Description:</strong></td>
<td><b><%=artCaseDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Dial Description:</strong></td>
<td><b><%=artDialDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Movement Description:</strong></td>
<td><b><%=artMovementDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Maker Description:</strong></td>
<td><b><%=artMakerDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Date Description:</strong></td>
<td><b><%=artDatDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Height Description:</strong></td>
<td><b><%=artHeightDesc%>&nbsp;</b></td>
</tr>
<tr>
<td height="29"><strong>Status:</strong></td>
<td><br>
<b><%=artStatus%></b> </td>
</tr>
<tr>
<td height="29"><strong>Display:</strong></td>
<td><br>
<b><%=artDisplay%></b> </td>
</tr>
<tr>
<td height="29"><strong>Moon Display:</strong></td>
<td><b><%=artMoonDisplay%>&nbsp;</b></td>
</tr>
<tr>
<td height="29">&nbsp;</td>
<td><br/><span class="style2">Was added to the database</span> </td>
</tr>
</table>
</center>
<p>
<%


end if


%>

<%
' Update Product
IF updateProduct <> "" THEN

if artPicFull = "" then

strsqlM = "UPDATE eventDisplay SET " &_
"art_Title='" & fixQuotes( artTitle ) & "', " &_
"art_Category='" & fixQuotes( artCategory ) & "', " &_
"art_BDescription='" & fixQuotes( artBriefDesc ) & "', " &_
"art_Price='" & fixQuotes( artPrice ) & "', " &_
"art_ThumbFace='" & fixQuotes( artFace ) & "', " &_
"art_ThumbHood='" & fixQuotes( artHood ) & "', " &_
"case_Text='" & fixQuotes(artCaseDesc ) & "', " &_
"dial_Text='" & fixQuotes(artDialDesc ) & "', " &_
"movement_Text='" & fixQuotes(artMovementDesc ) & "', " &_
"maker_Text='" & fixQuotes(artMakerDesc ) & "', " &_
"dat_Text='" & fixQuotes(artDatDesc ) & "', " &_
"height_Text='" & fixQuotes(artHeightDesc ) & "', " &_
"art_Status='" & fixQuotes( artStatus ) & "', " &_
"art_MoonDisplay=" & artMoonDisplay & ", " &_
"art_Display=" & artDisplay & " " &_
" WHERE " &_
"cat_ID=" & catID


else

strsqlM = "UPDATE eventDisplay SET " &_
"art_Title='" & fixQuotes( artTitle ) & "', " &_
"art_Category='" & fixQuotes( artCategory ) & "', " &_
"art_BDescription='" & fixQuotes( artBriefDesc ) & "', " &_
"art_Price='" & fixQuotes(artPrice ) & "', " &_
"art_ThumbFull='" & fixQuotes( artPicFull ) & "', " &_
"art_ThumbFace='" & fixQuotes( artFace ) & "', " &_
"art_ThumbHood='" & fixQuotes( artHood ) & "', " &_
"case_Text='" & fixQuotes(artCaseDesc ) & "', " &_
"dial_Text='" & fixQuotes(artDialDesc ) & "', " &_
"movement_Text='" & fixQuotes(artMovementDesc ) & "', " &_
"maker_Text='" & fixQuotes(artMakerDesc ) & "', " &_
"dat_Text='" & fixQuotes(artDatDesc ) & "', " &_
"height_Text='" & fixQuotes(artHeightDesc ) & "', " &_
"art_Status='" & fixQuotes( artStatus ) & "', " &_
"art_MoonDisplay=" & artMoonDisplay & ", " &_
"art_Display=" & artDisplay & " " &_
" WHERE " &_
"cat_ID=" & catID

end if

ConnM.Execute strsqlM

%>

<center>
<table width="600" cellpadding="4"
cellspacing="0" >
<tr>
<td>
<%=artTitle%> was updated in the database
<br/>
<br/>
</td>
</tr>
</table>
</center>
<%
END IF
%>

<center>
<table width="600" border="1" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2"><strong>
Edit Clock Information - </strong>If you want to edit information of a specific clock use the section below to select the Clock Title:</td>
</tr>
<tr>
<td align="center">
<table border="1" size="400" cellpadding="3" cellspacing="0">
<%
strsqlM = "SELECT cat_ID, art_Title FROM eventDisplay " &_
"ORDER BY art_Title"

set rs = server.createobject("adodb.recordset")
rs.activeconnection = ConnM
rs.open strsqlM
WHILE NOT rs.EOF
%>

<tr>
<td>

<a href="updateproduct_art.asp?pid=<%=rs( "cat_ID")%>"><%=rs( "art_Title" )%></a>
</td>
</tr>
<% rs.MoveNext
WEND

rs.close
set rs = nothing

ConnM.close
set ConnM = nothing
%>
</table>
</td>
</tr>
<tr>
<td>
<a href="../adminPage.asp"> Back </a>
</td>
</tr>
</table>
</center>
 
That's an awful lot of code to try to go through on a Friday afternoon... :)

Without going through everything because I just don't have the time right now, the best I can guess based on your description is that your update is working correctly for the first record. However, it then tries to update the data for the other two records but you're not actually passing it any data for those two records so, when it does the update, it "deletes" the data because you're passing it empty string values. So, either you need to prevent it from trying to update the other two records or you need to send the data for the other two records as well when doing the update. Does this make sense to you?

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top