webForumDet fria alternativet

Hjälp behövs till dinannons.se !

ASP

18 svar · 969 visningar · startad av Denniss

Medlem sedan maj 2003176 inlägg
Frågan#1

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

Medlem sedan aug. 20039 340 inlägg
#2

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.

Medlem sedan maj 2003176 inlägg
#3

<%
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>
 </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">
 <br>
 </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>
 </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
%>

Medlem sedan maj 2003176 inlägg
#4

Kan det vara fel hos webbhotell? Eller ?

Medlem sedan feb. 20032 027 inlägg
#5

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

Medlem sedan feb. 20032 027 inlägg
#6

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
Medlem sedan dec. 20025 483 inlägg
#7

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
%>
Medlem sedan maj 2003176 inlägg
#8

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

Medlem sedan dec. 200012 464 inlägg
#9

Rad 11:

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

är odefinierad.

Medlem sedan maj 2003176 inlägg
#10

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

Medlem sedan feb. 20032 027 inlägg
#11

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

Medlem sedan maj 2003176 inlägg
#12

Kan du skriva koden då ?

Tack för hjälpen.

Medlem sedan feb. 20032 027 inlägg
#13

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

Medlem sedan maj 2003176 inlägg
#14

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
%>

Medlem sedan maj 2003176 inlägg
#15

Någon ?

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

Medlem sedan juni 200032 967 inlägg
#16

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?

Medlem sedan maj 2003176 inlägg
#17

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.

Medlem sedan juni 200032 967 inlägg
#18

Har detta alltså funkat som det ska tidigare?

Vilket webhotell använder du?

Medlem sedan dec. 20003 887 inlägg
#19

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
270 ms totalt · 4 externa anrop · v20260731065814-full.6fe65c25
128 ms — deklarationer (db)
0 ms — hämta statistik (cache)
138 ms — hämta tråd, inlägg och bilagor (db)
129 ms — ändringar (db)