---
title: "Fel mess!"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/82166-fel-mess"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "paddan"
published: "2003-07-16T16:11:46.000Z"
updated: "2003-07-16T19:15:16.000Z"
replies: 16
views: 468
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/82166-fel-mess"
---

# Fel mess!

## #1 — paddan, 2003-07-16T16:11Z

Vad är fel på denna koden??

strSQL = "INSERT INTO members (hemsida) VALUES ('" & filename & "')" AND WHERE id=" & Session("id")

Fel mess:
Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/upload/upload_data.asp, line 75 

strSQL = "INSERT INTO members (hemsida) VALUES ('" & filename & "')" AND WHERE id=" & Session("id")
\-------------------------------------------------------------------------------^

Mvh Martin

Permalänk: https://www.webforum.nu/p/82166

## #2 — Josef, 2003-07-16T16:16Z

Du kan inte ha ett WHERE-argument i en insert-sats.

Permalänk: https://www.webforum.nu/p/1113323

## #3 — Qimen, 2003-07-16T16:17Z

Men då hade jag ju rätt \*gaah\* :OO  :e

Permalänk: https://www.webforum.nu/p/1113324

## #4 — LarsG, 2003-07-16T16:18Z

```
strSQL = "update members set hemsida = '" & filename _
& "'  WHERE id=" & Session("id")
```

En kontamination minsann.

Permalänk: https://www.webforum.nu/p/1113325

## #5 — Nickemannen, 2003-07-16T16:20Z

Du kan inte använda **INSERT** och **WHERE**

Du får använda **UPDATE** istället.

Ex:

```
strSql = "Update members Set hemsida = '"&filename&"' where id = "&Session("id")
```

// Red Gaaah, skulle inte hämtat colan då har ju jag varit först.

// Red men det var inte det som var felet det var ju

strSQL = "INSERT INTO members (hemsida) VALUES ('" & filename & "')**"** AND WHERE id=" & Session("id")

Permalänk: https://www.webforum.nu/p/1113326

## #6 — paddan, 2003-07-16T16:24Z

Hur blir dte nu killar??

Mvh Martin Sköld

Permalänk: https://www.webforum.nu/p/1113328

## #7 — paddan, 2003-07-16T16:26Z

Feltyp:
Microsoft JET Database Engine (0x80040E14)
Syntaxfel (operator saknas) i frågeuttrycket 'id ='.
/upload/upload_data.asp, line 77

med den koden!!

Permalänk: https://www.webforum.nu/p/1113330

## #8 — @nders, 2003-07-16T16:28Z

Då är session("id") tom.

Permalänk: https://www.webforum.nu/p/1113331

## #9 — paddan, 2003-07-16T16:46Z

Räcker denna kodne till att ladd aupp en bild och spra filnamnet i en databas??

Mvh Martin Sköld
\<%
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile\<\>0 AND (PosFile\<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value 
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl 
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop

End Sub

'String to byte string conversion
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

'Byte string to string conversion
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1))) 
Next
End Function
%\>

Permalänk: https://www.webforum.nu/p/1113342

## #10 — solbulle, 2003-07-16T16:52Z

Nej.

Permalänk: https://www.webforum.nu/p/1113352

## #11 — @nders, 2003-07-16T16:52Z

Det märker du väl enklast genom att testa? Det är inte lätt för oss att veta.

Använd \[kod\]-taggar så blir koden mer lättläst.

Permalänk: https://www.webforum.nu/p/1113353

## #12 — paddan, 2003-07-16T16:53Z

Är det någon som har en hel ladda upp kod där den när den är klar bara skickas till en annan sida...

Mvh Martin

Permalänk: https://www.webforum.nu/p/1113355

## #13 — @nders, 2003-07-16T16:55Z

Titta efter OveRRidEs uploadscript i scriptarkivet. Det brukar duga gott.

Mvh

Permalänk: https://www.webforum.nu/p/1113356

## #14 — solbulle, 2003-07-16T16:58Z

Men allvarligt Paddan, fungerar inte ditt script? Samma script har avhandlats en del här i forumet så det ska finnas en del info om det om du söker.

Vad är egentligen problemet?

OveRRides script är bra, men jag tvivlar på att du finner det lättare än detta, OM du inte söker o hittar de anpassningar som folk här i forumet gjort av det.

Permalänk: https://www.webforum.nu/p/1113359

## #15 — paddan, 2003-07-16T16:59Z

Har försökt modifera de men får inte rätt på det..
Allt jag vill är att man väljer bild på en sida och sedan skickas man till typ upload.asp och sedan tillbaka tillsidan man var innan..
Ingen sida där man ser det färdiga exemplet...
\+Så vill jag att filnamnet sparas i en databas..
Någon som kan hjälpa mig!

Permalänk: https://www.webforum.nu/p/1113360

## #16 — paddan, 2003-07-16T16:59Z

Men jag klarar inte det får inte rätt påd et liksom..!

Permalänk: https://www.webforum.nu/p/1113361

## #17 — solbulle, 2003-07-16T19:15Z

Nu du... se till att du har rätt filnamn på dina tre filer bara.

```
<!--#include file="upload_data.asp" -->
<%
If request.querystring("submit")="yes" THEN
Error = "0"

Response.Expires=0
Response.Buffer = TRUE
Response.Clear
'Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))
byteCount = Request.TotalBytes
'Response.BinaryWrite(Request.BinaryRead(varByteCount))

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

BuildUploadRequest RequestBin

'email = UploadRequest.Item("email").Item("Value")

contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value = UploadRequest.Item("blob").Item("Value")

If contentType="image/gif" OR contentType="image/pjpeg" THEN   'KOLLAR VAD DET ÄR FÖR TYP AV FIL, I DETTA FALL ENDAST .GIF ELLER .JPG BILDER
	If byteCount<=250000 THEN			'KONTROLLERAR STORLEKEN PÅ FILEN, HÄR 250 Kb MAX
		'Create FileSytemObject Component
		Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
	
		'Create and Write to a File
		pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
		' Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd)&filename)
		Set MyFile = ScriptObject.CreateTextFile(Server.mappath(filename))  'HÄR ÄNDRAR NI SÖKVÄGEN DÄR FILEN SKA SPARAS, HÄR I SAMMA KATALOG SOM UPLOAD_DONE.ASP LIGGER I
		'response.write(Server.mappath(filename)) 
	
		For i = 1 to LenB(value)
		MyFile.Write chr(AscB(MidB(value,i,1)))
		Next
		MyFile.Close

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("members.mdb")
'strSQL = "INSERT INTO members (filnamn) VALUES ('" & filename & "')"
strSql = "Update members Set hemsida = '"&filename&"' where id = "&Session("id")
objConn.Execute(strSQL)
objConn.Close : Set objConn = Nothing

response.redirect("uppladda.asp")

	Else
		Error = "Bilden får inte vara större än 250 kb"
	End If
Else
Error = "Du kan bara ladda upp GIF eller JPG bilder"
End If
End If
%>
<html>
<head>
<title>FEL!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<b><%
If Error<>"0" THEN
response.write "Uppladdningen misslyckades<br>"
response.write "Felet var: " & Error
Else
response.write "Uppladdning klar"
End If
%>
</b></font>
</body>
</html>
```

Permalänk: https://www.webforum.nu/p/1113418

---

Tråden på webben: https://www.webforum.nu/amne/asp/82166-fel-mess
