webForumDet fria alternativet

Körningsfel vid upload+info

ASP

4 svar · 214 visningar · startad av Asa

Medlem sedan dec. 20011 860 inlägg
Frågan#1

Har en sida där jag har flera fält och 2 uploadfält! Nu när jag ska ladda upp så får jag följande felmess:

Feltyp:
Körningsfel i Microsoft VBScript (0x800A01C9)
Nyckeln är redan associerad med ett element i mängden.
/jobb/pockit/inc/function.asp, line 36

Har letat och letat men jag hittar inget som verkar vara samma namn i min kod. Min kod:

[b]DEL 1[/b]
<%If Request.QueryString("do") = "" Then

Set RS=Conn.Execute("Select * From shop_products Where id=" & Request.QueryString("id"))%>

<table width="100%" border="0" align="center">
<form action="changeProduct.asp?do=update&id=<%=RS("id")%>" method="post" name="prodform" enctype="multipart/form-data">
  <tr>
     <td colspan="4"><span class="urubrik">Ändra produkt</span></td>
  </tr>
  <tr>
    <td colspan="4" align="center"><hr size="1" noshade color="<%=Color1%>"></td>
  </tr>
  <tr>
    <td width="50%" colspan="2"><b>Märke: </b><br><input type="text" name="mark" style="width:100%" value="<%=RS("mark")%>"></td>
    <td width="25%"><b>Modell: </b><br><input type="text" name="modell" style="width:100%" value="<%=RS("modell")%>"></td>
    <td width="25%"><b>Kategori: </b><br>
      <%Set Cat=Conn.Execute("Select * From shop_category Order By category")%>
      <SELECT name="category" style="width:100%" onchange="checkcat()">
        <OPTION value="#"> -- Välj kategori -- </OPTION>
        <%Do Until Cat.EOF%>
            <OPTION value="<%=Cat("id")%>" <%If Cint(Cat("id")) = Cint(RS("cat")) Then Response.Write " Selected"%>><%=Cat("Category")%></OPTION>
        <%Cat.MoveNext
        Loop%>
      </SELECT>
    </td>
  </tr>
  <tr>
    <td width="50%" colspan="2"><b>ProduktNamn: </b><br><input type="text" name="product" style="width:100%" value="<%=RS("product")%>"></td>
    <td width="25%"><b>Pris: </b><br><input type="text" name="price" style="width:100%" value="<%=RS("price")%>"></td>
    <td width="25%"><b>Aktiv: </b><br>
      <SELECT name="active" style="width:100%">
        <OPTION value="1" <%If RS("active") = 1 Then Response.Write " selected"%>>Ja</OPTION>
        <OPTION value="0" <%If RS("active") = 0 Then Response.Write " selected"%>>Nej</OPTION>
      </SELECT>
    </td>
  </tr>
  <tr>
    <td colspan="2"><b>Stor produktbild: </b> <%If RS("picture1") <> "" Then%><a href="../gfx/products/<%=RS("picture1")%>">Bilden</a><%ENd If%><br><input type="file" name="picture" style="width:100%"></td>
    <td colspan="2"><b>Liten produktbild: </b> <%If RS("picture2") <> "" Then%><a href="../gfx/products/<%=RS("picture2")%>">Bilden</a><%ENd If%><br><input type="file" name="picture2" style="width:100%"></td>
  </tr>
  <tr>
    <td colspan="4"><b>ProduktBeskrivning: </b><br><textarea style="width:100%" rows="5" name="descr"><%=RS("descr")%></textarea></td>
  </tr>
</table>
<div id="visa_1" style="z-index:1; position:relative; display:none;">
  <table width="100%">
    <tr>
      <td width="35%">
        <b>Vikt:</b> (g)<br>
        <input type="text" name="vikt" style="width:100%" value="<%=RS("vikt")%>">
      </td>
      <td width="35%">
        <b>Mått:</b> (HxBxD)<br>
        <input type="text" name="matt" style="width:100%" value="<%=RS("matt")%>">
      </td>
      <td width="15%">
        <b>IR-port:</b><br>
        <SELECT name="ir" style="width:100%">
          <OPTION value="1" <%If RS("ir") = 1 Then Response.Write " selected"%>>Ja</OPTION>
          <OPTION value="0" <%If RS("ir") = 0 Then Response.Write " selected"%>>Nej</OPTION>
        </SELECT>
      </td>
      <td width="15%">
        <b>GPRS:</b><br>
        <SELECT name="gprs" style="width:100%">
          <OPTION value="1" <%If RS("gprs") = 0 Then Response.Write " selected"%>>Ja</OPTION>
          <OPTION value="0" <%If RS("gprs") = 1 Then Response.Write " selected"%>>Nej</OPTION>
        </SELECT>
      </td>
    </tr>
    <tr>
      <td width="35%">
        <b>Passningstid:</b> (tim)<br>
        <input type="text" name="pass" style="width:100%" value="<%=RS("pass")%>">
      </td>
      <td width="35%">
        <b>Samtalstid:</b> (tim)<br>
        <input type="text" name="samt" style="width:100%" value="<%=RS("samt")%>">
      </td>
      <td width="15%">
        <b>BlueTooth:</b><br>
        <SELECT name="bt" style="width:100%">
          <OPTION value="1" <%If RS("bt") = 1 Then Response.Write " selected"%>>Ja</OPTION>
          <OPTION value="0" <%If RS("bt") = 0 Then Response.Write " selected"%>>Nej</OPTION>
        </SELECT>
      </td>
      <td width="15%">
        &nbsp;
      </td>
    </tr>
  </table>
</div>
<div id="visa_3" style="z-index:1; position:relative; display:none;">
  <table width="100%">
    <tr>
      <td width="25%">
        <b>Passningstid:</b> (tim)<br>
        <input type="text" name="pass" style="width:100%" value="<%=RS("pass")%>">
      </td>
      <td width="25%">
        <b>Vikt:</b> (g)<br>
        <input type="text" name="vikt" style="width:100%" value="<%=RS("vikt")%>">
      </td>
      <td width="25%">
        <b>Mått:</b> (HxBxD)<br>
        <input type="text" name="matt" style="width:100%" value="<%=RS("matt")%>">
      </td>
      <td width="25%">
        <b>Skärm:</b><br>
        <input type="text" name="skarm" style="width:100%" value="<%=RS("skarm")%>">
      </td>
    </tr>
    <tr>
      <td width="25%">
        <b>OS:</b><br>
        <input type="text" name="os" style="width:100%" value="<%=RS("os")%>">
      </td>
      <td width="25%">
        <b>RAM:</b><br>
        <input type="text" name="ram" style="width:100%" value="<%=RS("ram")%>">
      </td>
      <td width="25%">
        <b>Processor:</b><br>
        <input type="text" name="proc" style="width:100%" value="<%=RS("proc")%>">
      </td>
      <td width="25%">
        &nbsp;
      </td>
    </tr>
  </table>
</div>
<div id="visa_6" style="z-index:1; position:relative; display:none;">
  <table width="100%">
    <tr>
      <td>
        <b>Bindningstid:</b> (mån)<br>
        <SELECT name="bind" style="width:100%">
          <OPTION value="0" <%If RS("bind") = 0 Then Response.Write " selected"%>>0</OPTION>
          <OPTION value="6" <%If RS("bind") = 6 Then Response.Write " selected"%>>6</OPTION>
          <OPTION value="12" <%If RS("bind") = 12 Then Response.Write " selected"%>>2</OPTION>
          <OPTION value="18" <%If RS("bind") = 18 Then Response.Write " selected"%>>18</OPTION>
          <OPTION value="24" <%If RS("bind") = 24 Then Response.Write " selected"%>>24</OPTION>
        </SELECT>
      </td>
    </tr>
  </table>
</div>
<table width="100%">
  <tr> 
     <td colspan="3"><input type="submit" name="submit" value="Ändra produkten" class="knapp"></td>
  </tr>
</form>
</table>
Medlem sedan dec. 20011 860 inlägg
#2
[b]DEL 2[/b]
<%ElseIf Request.QueryString("do") = "update" Then

byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Set UploadRequest = CreateObject("Scripting.Dictionary")

BuildUploadRequest RequestBin

filepathname  = UploadRequest.Item("picture").Item("FileName")
filepathname2  = UploadRequest.Item("picture2").Item("FileName")
filename      = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
filename2      = Right(filepathname2,Len(filepathname2)-InstrRev(filepathname2,"\"))
value         = UploadRequest.Item("picture").Item("Value")
value2         = UploadRequest.Item("picture2").Item("Value")

Product       = UploadRequest.Item("product").Item("Value")
Price         = UploadRequest.Item("price").Item("Value")
Descr         = UploadRequest.Item("descr").Item("Value")
Mark          = UploadRequest.Item("mark").Item("Value")
Modell        = UploadRequest.Item("modell").Item("Value")
Active        = UploadRequest.Item("active").Item("Value")
Category      = UploadRequest.Item("category").Item("Value")

If Category = "1" Then
  vikt = UploadRequest.Item("vikt").Item("Value")
  matt = UploadRequest.Item("matt").Item("Value")
  ir   = UploadRequest.Item("ir").Item("Value")
  gprs = UploadRequest.Item("gprs").Item("Value")
  bt   = UploadRequest.Item("bt").Item("Value")
  pass = UploadRequest.Item("pass").Item("Value")
  samt = UploadRequest.Item("samt").Item("Value")

  Conn.Execute("Update shop_products Set picture1='" & filename & "', picture2='" & filename2 & "',product='" & Product & "',price=" & Price & ",descr='" & Descr & "',cat=" & Category & ",bind='" & bind & "',vikt='" & vikt & "',matt='" & matt & "',ir='" & ir & "',gprs='" & gprs & "',bt='" & bt & "',pass='" & pass & "',samt='" & samt & "' Where id=" & Request.QueryString("id"))
ElseIf Category = "1" Then
  vikt  = UploadRequest.Item("vikt").Item("Value")
  matt  = UploadRequest.Item("matt").Item("Value")
  os    = UploadRequest.Item("os").Item("Value")
  skarm = UploadRequest.Item("skarm").Item("Value")
  ram   = UploadRequest.Item("ram").Item("Value")
  pass  = UploadRequest.Item("pass").Item("Value")
  proc  = UploadRequest.Item("proc").Item("Value")

  Conn.Execute("Update shop_products Set picture1='" & filename & "', picture2='" & filename2 & "',product='" & Product & "',price=" & Price & ",descr='" & Descr & "',cat=" & Category & ",bind='" & bind & "',vikt='" & vikt & "',matt='" & matt & "',os='" & os & "',skarm='" & skarm & "',ram='" & ram & "',pass='" & pass & "',proc='" & proc & "' Where id=" & Request.QueryString("id"))
ElseIf Category = "1" Then
  bind  = UploadRequest.Item("bind").Item("Value")

  Conn.Execute("Update shop_products Set picture1='" & filename & "', picture2='" & filename2 & "',product='" & Product & "',price=" & Price & ",descr='" & Descr & "',cat=" & Category & ",bind='" & bind & "' Where id=" & Request.QueryString("id"))
Else
  Conn.Execute("Update shop_products Set picture1='" & filename & "', picture2='" & filename2 & "',product='" & Product & "',price=" & Price & ",descr='" & Descr & "',cat=" & Category & " Where id=" & Request.QueryString("id"))
End If

Set RS=Conn.Execute("Select Top 1 * From shop_products Order By id desc")
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
  filnamn = RS("picture1")
  filnamn2 = RS("picture2")
extension = right(filnamn,len(filnamn) - instr(filnamn,".") +1)
Filen = "product_" & RS("id")
filnamn = Filen & extension

extension2 = right(filnamn2,len(filnamn2) - instr(filnamn2,".") +1)
Filen2 = "product_thumb_" & RS("id")
filnamn2 = Filen2 & extension2

pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
If filename1 <> "" Then
  Set MyFile = ScriptObject.CreateTextFile(Server.mappath("../gfx/products/" & filnamn))
    For i = 1 to LenB(value)
      MyFile.Write chr(AscB(MidB(value,i,1)))
    Next
  MyFile.Close
  Conn.Execute("Update shop_products Set picture1='" & filnamn & "' Where id=" & RS("id"))
ENd If

If filename2 <> "" Then
  Set MyFile = ScriptObject.CreateTextFile(Server.mappath("../gfx/products/" & filnamn2))
    For i = 1 to LenB(value2)
      MyFile.Write chr(AscB(MidB(value2,i,1)))
    Next
  MyFile.Close
  Conn.Execute("Update shop_products Set picture2='" & filnamn2 & "' Where id=" & RS("id"))
ENd If

Response.Redirect "Products.asp"
End If%>
Medlem sedan mars 20015 287 inlägg
#3

Vilken rad är 36?

Medlem sedan dec. 20011 860 inlägg
#4

Jag hittade felet! Var tvungen att ge alla inputfält olika namn. För den tog med alla formulärfält.

Medlem sedan mars 20015 287 inlägg
#5

Oki, bra.

277 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
122 ms — deklarationer (db)
0 ms — hämta statistik (cache)
145 ms — hämta tråd, inlägg och bilagor (db)
129 ms — ändringar (db)