---
title: "Hjälp behövs till dinannons.se !"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/141438-hjälp-behövs-till-dinannons-se"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Denniss"
published: "2006-01-24T16:57:00.000Z"
updated: "2006-01-26T11:20:55.000Z"
replies: 18
views: 973
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/141438-hjälp-behövs-till-dinannons-se"
---

# Hjälp behövs till dinannons.se !

## #1 — Denniss, 2006-01-24T16:57Z

Hej !

När man vill lägga in ny annons och vill lägga in en bild , då händer något konstigt med sidan . Någon som kan titta på det ?

<http://www.dinannons.se>

MVH

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

## #2 — nitro2k01, 2006-01-24T17:02Z

Du får nog allt ta och visa källkoden till andra_ta_bort_bild.asp
Det står 500 internt serverfel, vilket är en flekod för precis vad det låter som, nämligen att något har gått fel på servern.

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

## #3 — Denniss, 2006-01-24T17:04Z

\<%
Response.Buffer = True
Response.Expires = -1500
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"

Set Connect = Server.CreateObject("ADODB.Connection") 
Connect.Open "driver={Microsoft Access Driver (\*.mdb)};dbq=" & Server.MapPath("Annons.mdb")&""
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select \* From Annonser where AnnonsID="&session("AnnonsID")
RecSet.Open Addera, Connect, 3, 3
%\>

\<%
Function FileUpload(strPath, intMaxSize, arrAcceptType, arrAcceptExt, ByRef strContentType, ByRef strFilename, ByRef intFileTotalBytes)

Dim intPostTotalBytes, intStartPos, intEndPos, i
Dim bstrPostData, bstrDivider
Dim strTemp, strFileSpec
Dim arrSplit
Dim vbCrLfB
Dim bolStopLoop, bolContentTypeOK, bolExtOK
Dim fs, ts, f

strContentType = ""
strFilename = ""
intFileTotalBytes = 0

If Request.querystring("laddaupp") = "ja" Then

vbCrLfB = ChrB(13) & ChrB(10)
intPostTotalBytes = Request.TotalBytes
bstrPostData = Request.BinaryRead(intPostTotalBytes)
If LenB(bstrPostData) \<\> intPostTotalBytes Then
FileUpload = 1
Exit Function
End If
bstrDivider = LeftB(bstrPostData, InStrB(bstrPostData, vbCrLfB) + 1)

intStartPos = 1
   
bolStopLoop = False
Do
intStartPos = InStrB(intStartPos, bstrPostData, bstrDivider) + LenB(bstrDivider)
If intStartPos = 0 Then
FileUpload = 2
Exit Function
End If

intEndPos = InStrB(intStartPos, bstrPostData, bstrDivider)
If intEndPos = 0 Then
FileUpload = 2
Exit Function
End If

strTemp = bin2str(MidB(bstrPostData, intStartPos, InStrB(intStartPos, bstrPostData, vbCrLfB) - intStartPos))
If InStr(LCase(strTemp), "name=""bild""") \> 0 Then
bolStopLoop = True
Else
intStartPos = intEndPos
End If
Loop Until bolStopLoop
intStartPos = intStartPos + Len(strTemp) + 2
arrSplit = Split(strTemp, ";")
strTemp = ""
For i = 0 To UBound(arrSplit)
If LCase(Left(Trim(arrSplit(i)), 9)) = "filename=" Then
strTemp = Trim(arrSplit(i))
Exit For
End If
Next
If strTemp = "" Or strTemp = "filename=""""" Then
FileUpload = 3
Exit Function
End If

arrSplit = Split(strTemp, """")
strTemp = arrSplit(UBound(arrSplit) - 1)
arrSplit = Split(strTemp, "\\") 
strFilename = arrSplit(UBound(arrSplit)) 
strFileSpec = Server.MapPath(LCase(strPath &recset("AnnonsID")&"\_0"&recset("AnnonsID")& Replace(fix(recset("datum")),"-","")+696969&"."&right(strFilename,3)))
strTemp = bin2str(MidB(bstrPostData, intStartPos, InStrB(intStartPos, bstrPostData, vbCrLfB) - intStartPos))
intStartPos = intStartPos + Len(strTemp) + 2

arrSplit = Split(strTemp, " ")
strContentType = arrSplit(UBound(arrSplit))
bolContentTypeOK = False
If arrAcceptType(LBound(arrAcceptType)) \<\> "" Then
For Each strTemp In arrAcceptType
If strContentType = strTemp Then
bolContentTypeOK = True
End If
Next

If Not bolContentTypeOK Then
FileUpload = 4
Exit Function
End If
End If

bolExtOK = False
If arrAcceptExt(LBound(arrAcceptExt)) \<\> "" Then
For Each strTemp In arrAcceptExt
If LCase(Right(strFilename, Len(strTemp))) = strTemp Then
bolExtOK = True
End If
Next

If Not bolExtOK Then
FileUpload = 5
Exit Function
End If
End If

intStartPos = intStartPos + 2
intEndPos = intEndPos - 2
intFileTotalBytes = intEndPos - intStartPos

If intMaxSize \> 0 Then
If intFileTotalBytes \> intMaxSize Then
FileUpload = 6
Exit Function
End If
End If

Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.CreateTextFile(strFileSpec, True)
For i = intStartPos To intEndPos - 1
ts.Write(Chr(AscB(MidB(bstrPostData, i, 1))))
Next
ts.Close

Set f = fs.GetFile(strFileSpec)
If f.Size \<\> intFileTotalBytes Then
FileUpload = 7
Exit Function
End If

FileUpload = 0
End If
End Function

Function bin2str(bstrBinary)
Dim i
For i = 1 To LenB(bstrBinary)
  bin2str = bin2str & Chr(AscB(MidB(bstrBinary, i, 1)))
Next
End Function
%\>
\<body topmargin="0" leftmargin="0" link="#000000" vlink="#000000" alink="#000000"\>
\<table cellSpacing="0" cellPadding="7" width="100%" border="0"\>
  \<tr\>
    \<td class="verdana2"\>Lägg till en bild på din pryl om så önskas. \<br\>
    \<br\>
&nbsp;\</td\>
  \</tr\>
  \<tr\>
    \<td class="verdana2"\>
    \<form method="POST" enctype="multipart/form-data" action="andra_ta_bort_bild.asp?laddaupp=ja"\>
    \<input style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FONT-SIZE: xx-small; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; FONT-FAMILY: verdana; HEIGHT: 20px; BACKGROUND-COLOR: whitesmoke" type="file" size="50" name="bild"\>\</p\>
    \<input style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 100px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" type="submit" value="Ladda upp bild" name="submitbild"\>\</p\>
    \</form\>
    \</td\>
  \</tr\>
  \<tr\>
    \<td class="verdana2"\>
    &nbsp;\<br\>
&nbsp;\</td\>
  \</tr\>
\</table\>
\<table cellSpacing="0" cellPadding="7" width="100%" border="0"\>
  \<tr\>
    \<td class="verdana2"\>\<center\>\<%if not recset("bild") = "" then%\>
    \<p\>Din nuvarande bild:\<br\>
    \<br\>
\<img src="bilder/\<%=recset("bild")%\>"\>    \<br\>
    \<br\>
    \<input type="button" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 80px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" onclick="self.location.href='andra_ta_bort_bild_nu.asp?AnnonsID=\<%=Recset("AnnonsID")%\>&Losenord=\<%=recset("Losenord")%\>'"value="Ta bort bild" name="tabortbild" size="20"\>
    \<br\>
    \<br\>
    \<br\>
&nbsp;\</p\>\<%end if%\>
    \</center\>\</td\>
  \</tr\>
  \<tr\>
    \<td align="right"\>
    \<input style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 50px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" onclick="javascript:window.close();" type="button" value="Stäng" name="close"\>\</td\>
  \</tr\>
\</table\>
\<%
    if request.querystring("laddaupp") = "ja" then
        Dim intFileUpload, strContentType, strFilename, intFileTotalBytes

        intFileUpload = FileUpload("Bilder/", 200000, Array("image/gif", "image/jpeg", "image/pjpeg"), Array("gif", "jpg"), strContentType, strFilename, intFileTotalBytes)

        If intFileUpload = 0 Then
            Response.Write "Filen " & strFilename & " blev uppladat.\<BR\>"
            recset("Bild") = recset("AnnonsID")&"\_0"&recset("AnnonsID")& Replace(fix(recset("datum")),"-","")+696969&"."&right(strFilename,3)
   recset.update
   response.redirect "andra_ta_bort_bild.asp"
        Else  
            Response.Write "Det uppstod ett fel under uppladdningen!\<BR\>"
            Response.Write "Fel nummer: " & intFileUpload & "\<BR\>"
            Response.Write "Filnamn: " & strFilename & "\<BR\>"
            Response.Write "Filtyp: " & strContentType & "\<BR\>"
            Response.Write "Filstorlek: " & intFileTotalBytes & "\<BR\>"
        End If
    End If
%\>
\<%
connect.close
set connect = nothing
%\>

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

## #4 — Denniss, 2006-01-24T17:40Z

Kan det vara fel hos webbhotell? Eller ?

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

## #5 — WebbisNet, 2006-01-24T18:18Z

Som många säger, använd kod-taggen och felstavningar ger inget seriöst intryck

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

## #6 — WebbisNet, 2006-01-24T18:23Z

sen får jag detta fel

```
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'AnnonsID='.

/andra_ta_bort_bild.asp, line 11
```

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

## #7 — Peter S, 2006-01-24T18:30Z

Med kodtaggar

```
<%
Response.Buffer = True
Response.Expires = -1500
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("Annons.mdb")&""
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select * From Annonser where AnnonsID="&session("AnnonsID")
RecSet.Open Addera, Connect, 3, 3
%>

<%
Function FileUpload(strPath, intMaxSize, arrAcceptType, arrAcceptExt, ByRef strContentType, ByRef strFilename, ByRef intFileTotalBytes)

Dim intPostTotalBytes, intStartPos, intEndPos, i
Dim bstrPostData, bstrDivider
Dim strTemp, strFileSpec
Dim arrSplit
Dim vbCrLfB
Dim bolStopLoop, bolContentTypeOK, bolExtOK
Dim fs, ts, f

strContentType = ""
strFilename = ""
intFileTotalBytes = 0

If Request.querystring("laddaupp") = "ja" Then

vbCrLfB = ChrB(13) & ChrB(10)
intPostTotalBytes = Request.TotalBytes
bstrPostData = Request.BinaryRead(intPostTotalBytes)
If LenB(bstrPostData) <> intPostTotalBytes Then
FileUpload = 1
Exit Function
End If
bstrDivider = LeftB(bstrPostData, InStrB(bstrPostData, vbCrLfB) + 1)

intStartPos = 1

bolStopLoop = False
Do
intStartPos = InStrB(intStartPos, bstrPostData, bstrDivider) + LenB(bstrDivider)
If intStartPos = 0 Then
FileUpload = 2
Exit Function
End If

intEndPos = InStrB(intStartPos, bstrPostData, bstrDivider)
If intEndPos = 0 Then
FileUpload = 2
Exit Function
End If

strTemp = bin2str(MidB(bstrPostData, intStartPos, InStrB(intStartPos, bstrPostData, vbCrLfB) - intStartPos))
If InStr(LCase(strTemp), "name=""bild""") > 0 Then
bolStopLoop = True
Else
intStartPos = intEndPos
End If
Loop Until bolStopLoop
intStartPos = intStartPos + Len(strTemp) + 2
arrSplit = Split(strTemp, ";")
strTemp = ""
For i = 0 To UBound(arrSplit)
If LCase(Left(Trim(arrSplit(i)), 9)) = "filename=" Then
strTemp = Trim(arrSplit(i))
Exit For
End If
Next
If strTemp = "" Or strTemp = "filename=""""" Then
FileUpload = 3
Exit Function
End If

arrSplit = Split(strTemp, """")
strTemp = arrSplit(UBound(arrSplit) - 1)
arrSplit = Split(strTemp, "\")
strFilename = arrSplit(UBound(arrSplit))
strFileSpec = Server.MapPath(LCase(strPath &recset("AnnonsID")&"_0"&recset("AnnonsID")& Replace(fix(recset("datum")),"-","")+696969&"."&right(strFilename,3)))
strTemp = bin2str(MidB(bstrPostData, intStartPos, InStrB(intStartPos, bstrPostData, vbCrLfB) - intStartPos))
intStartPos = intStartPos + Len(strTemp) + 2

arrSplit = Split(strTemp, " ")
strContentType = arrSplit(UBound(arrSplit))
bolContentTypeOK = False
If arrAcceptType(LBound(arrAcceptType)) <> "" Then
For Each strTemp In arrAcceptType
If strContentType = strTemp Then
bolContentTypeOK = True
End If
Next

If Not bolContentTypeOK Then
FileUpload = 4
Exit Function
End If
End If

bolExtOK = False
If arrAcceptExt(LBound(arrAcceptExt)) <> "" Then
For Each strTemp In arrAcceptExt
If LCase(Right(strFilename, Len(strTemp))) = strTemp Then
bolExtOK = True
End If
Next

If Not bolExtOK Then
FileUpload = 5
Exit Function
End If
End If

intStartPos = intStartPos + 2
intEndPos = intEndPos - 2
intFileTotalBytes = intEndPos - intStartPos

If intMaxSize > 0 Then
If intFileTotalBytes > intMaxSize Then
FileUpload = 6
Exit Function
End If
End If

Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.CreateTextFile(strFileSpec, True)
For i = intStartPos To intEndPos - 1
ts.Write(Chr(AscB(MidB(bstrPostData, i, 1))))
Next
ts.Close

Set f = fs.GetFile(strFileSpec)
If f.Size <> intFileTotalBytes Then
FileUpload = 7
Exit Function
End If

FileUpload = 0
End If
End Function

Function bin2str(bstrBinary)
Dim i
For i = 1 To LenB(bstrBinary)
bin2str = bin2str & Chr(AscB(MidB(bstrBinary, i, 1)))
Next
End Function
%>
<body topmargin="0" leftmargin="0" link="#000000" vlink="#000000" alink="#000000">
<table cellSpacing="0" cellPadding="7" width="100%" border="0">
<tr>
<td class="verdana2">Lägg till en bild på din pryl om så önskas. <br>
<br>
&nbsp;</td>
</tr>
<tr>
<td class="verdana2">
<form method="POST" enctype="multipart/form-data" action="andra_ta_bort_bild.asp?laddaupp=ja">
<input style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FONT-SIZE: xx-small; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; FONT-FAMILY: verdana; HEIGHT: 20px; BACKGROUND-COLOR: whitesmoke" type="file" size="50" name="bild"></p>
<input style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 100px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" type="submit" value="Ladda upp bild" name="submitbild"></p>
</form>
</td>
</tr>
<tr>
<td class="verdana2">
&nbsp;<br>
&nbsp;</td>
</tr>
</table>
<table cellSpacing="0" cellPadding="7" width="100%" border="0">
<tr>
<td class="verdana2"><center><%if not recset("bild") = "" then%>
<p>Din nuvarande bild:<br>
<br>
<img src="bilder/<%=recset("bild")%>"> <br>
<br>
<input type="button" style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 80px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" onclick="self.location.href='andra_ta_bort_bild_nu.asp?AnnonsID=<%=Recset("AnnonsID")%>&Losenord=<%=recset("Losenord")%>'"value="Ta bort bild" name="tabortbild" size="20">
<br>
<br>
<br>
&nbsp;</p><%end if%>
</center></td>
</tr>
<tr>
<td align="right">
<input style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: xx-small; BORDER-BOTTOM-WIDTH: 1px; WIDTH: 50px; CURSOR: hand; FONT-FAMILY: verdana; BORDER-RIGHT-WIDTH: 1px" onclick="javascript:window.close();" type="button" value="Stäng" name="close"></td>
</tr>
</table>
<%
if request.querystring("laddaupp") = "ja" then
Dim intFileUpload, strContentType, strFilename, intFileTotalBytes

intFileUpload = FileUpload("Bilder/", 200000, Array("image/gif", "image/jpeg", "image/pjpeg"), Array("gif", "jpg"), strContentType, strFilename, intFileTotalBytes)

If intFileUpload = 0 Then
Response.Write "Filen " & strFilename & " blev uppladat.<BR>"
recset("Bild") = recset("AnnonsID")&"_0"&recset("AnnonsID")& Replace(fix(recset("datum")),"-","")+696969&"."&right(strFilename,3)
recset.update
response.redirect "andra_ta_bort_bild.asp"
Else
Response.Write "Det uppstod ett fel under uppladdningen!<BR>"
Response.Write "Fel nummer: " & intFileUpload & "<BR>"
Response.Write "Filnamn: " & strFilename & "<BR>"
Response.Write "Filtyp: " & strContentType & "<BR>"
Response.Write "Filstorlek: " & intFileTotalBytes & "<BR>"
End If
End If
%>
<%
connect.close
set connect = nothing
%>
```

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

## #8 — Denniss, 2006-01-24T18:54Z

var ligger felet ? Jag kan inte det så bra.

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

## #9 — LarsG, 2006-01-24T19:25Z

Rad 11:

```
Addera = "Select * From Annonser where AnnonsID="&session("AnnonsID")
```

```
session("AnnonsID")
```

är odefinierad.

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

## #10 — Denniss, 2006-01-24T19:33Z

Hur definierar man det ? Varifrån skall den hämta något värde ?

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

## #11 — WebbisNet, 2006-01-24T19:46Z

När annonsen är inlagd så är det ju bättre att hämta radnumret från databasen eller skicka med AnnonsID i en querystring och sen fånga upp den på sida 2

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

## #12 — Denniss, 2006-01-24T20:04Z

Kan du skriva koden då ?

Tack för hjälpen.

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

## #13 — WebbisNet, 2006-01-24T20:09Z

din_sida.asp?aid=\<%=recset("annonsid")%\>

och sen på sida 2
varAID=request.querystring("aid")
Addera = "Select \* From Annonser where AnnonsID="& varAID)

@nders eller Lars G är bättre på detta

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

## #14 — Denniss, 2006-01-24T20:31Z

Hur kan koden se ut ?

\<%
Response.Buffer = True
Response.Expires = -1500
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (\*.mdb)};dbq=" & Server.MapPath("Annons.mdb")&""
Set RecSet = Server.CreateObject("ADODB.Recordset")
Addera = "Select \* From Annonser where AnnonsID="&session("AnnonsID")
RecSet.Open Addera, Connect, 3, 3
%\>

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

## #15 — Denniss, 2006-01-25T20:02Z

Någon ?

Kan det vara att webhotell har gjort/uppdaterat något som gör att jag får intern fel 500 ??

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

## #16 — @nders, 2006-01-25T21:02Z

Börja med att stänga av "Egna http-felmeddelanden" / "Friendly http error messages" i IE så du får ett vettigt felmeddelande.

Har detta alltså funkat som det ska tidigare?

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

## #17 — Denniss, 2006-01-26T10:50Z

Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 

\[Microsoft\]\[ODBC Microsoft Access Driver\] Syntax error (missing operator) in query expression 'AnnonsID='. 

/andra_ta_bort_bild.asp, line 11 

Jag ringde webhotell och de har inte ändrat/uppdaterat något.

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

## #18 — @nders, 2006-01-26T11:01Z

> Har detta alltså funkat som det ska tidigare?

Vilket webhotell använder du?

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

## #19 — Engine^, 2006-01-26T11:20Z

> **Denniss skrev:**
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 
> 
> \[Microsoft\]\[ODBC Microsoft Access Driver\] Syntax error (missing operator) in query expression 'AnnonsID='. 
> 
> /andra_ta_bort_bild.asp, line 11 
> 
> 
> Jag ringde webhotell och de har inte ändrat/uppdaterat något.

Som LarsG påpekade. Den variabeln du försöker stoppa in är tom. Sätt den till något defaultvärde om den är tom...

```
if( len( session( "AnnonsId" ) ) = 0 ) then session( "AnnonsId" ) = -1
```

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/141438-hjälp-behövs-till-dinannons-se
