Indviklet ASP script, der ikke virker
Følgene script, som jeg har fået lavet af en ufattelig venlig person, virker desværre ikke. Jeg kommer slet ikke "igang" med scriptet, men får enHTTP 500 - Intern serverfejl
(Siden kan ikke vises)
Nogen der kan gennemskue dette komplekse script?
<%
' Databaseforbindelse - husk at angive sti til din database
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("/db/akvarie.MDB")
Conn.Open DSN
if request("oprindelse1") <> "" or request("oprindelse2") <> "" or
request("oprindelse3") <> "" or request("oprindelse4") <> "" or
request("oprindelse5") <> "" then oprindelse = "ok" end if
if request("ph1") <> "" or request("ph2") <> "" or request("ph3") <> "" then
ph = "ok" end if
if request("dh1") <> "" or request("dh2") <> "" or request("dh3") <> "" or
request("dh4") <> "" or request("dh5") <> "" then dh = "ok" end if
if request("temp1") <> "" or request("temp2") <> "" or request("temp3") <>
"" or request("temp4") <> "" then temp = "ok" end if
if request("omr1") <> "" or request("omr2") <> "" or request("omr3") <> ""
or request("omr4") <> "" or request("omr5") <> "" then temp = "ok" end if
if request("str1") <> "" or request("str2") <> "" or request("str3") <> ""
or request("str4") <> "" or request("str5") <> "" then str = "ok" end if
if request("mastr1") <> "" or request("mastr2") <> "" or request("mastr3")
<> "" or request("mastr4") <> "" or request("mastr5") <> "" then mastr =
"ok" end if
if oprindelse = "ok" or ph = "ok" or dh = "ok" or temp = "ok" or omr = "ok"
or str = "ok" or mastr = "ok" then
' SQL forespørgsel
strSQL = "Select * from Cichlider where "
else
' SQL forespørgsel
strSQL = "Select * from Cichlider"
end if
'Oprindelse
if oprindelse = "ok" then strSQL = strSQL & "("
if request("oprindelse1") <> "" then
strSQL = strSQL & "oprindelse='" & request("oprindelse1") & "' "
end if
if request("oprindelse1") <> "" and request("oprindelse2") <> "" then strSQL
= strSQL & "or " end if
if request("oprindelse2") <> "" then
strSQL = strSQL & "oprindelse='" & request("oprindelse2") & "' "
end if
if request("oprindelse2") <> "" and request("oprindelse3") <> "" then strSQL
= strSQL & "or " end if
if request("oprindelse3") <> "" then
strSQL = strSQL & "oprindelse='" & request("oprindelse3") & "' "
end if
if request("oprindelse3") <> "" and request("oprindelse4") <> "" then strSQL
= strSQL & "or " end if
if request("oprindelse4") <> "" then
strSQL = strSQL & "oprindelse='" & request("oprindelse4") & "' "
end if
if request("oprindelse4") <> "" and request("oprindelse5") <> "" then strSQL
= strSQL & "or " end if
if request("oprindelse5") <> "" then
strSQL = strSQL & "oprindelse='" & request("oprindelse5") & "' "
end if
'pH
if oprindelse = "ok" then strSQL = strSQL & ") and " end if
if ph = "ok" then strSQL = strSQL & "(" end if
if request("ph1") <> "" then
strSQL = strSQL & "ph='" & request("ph1") & "' "
end if
if request("ph1") <> "" and request("ph2") <> "" then strSQL = strSQL & "or
" end if
if request("ph2") <> "" then
strSQL = strSQL & "ph='" & request("ph2") & "' "
end if
if request("ph2") <> "" and request("ph3") <> "" then strSQL = strSQL & "or
" end if
if request("ph3") <> "" then
strSQL = strSQL & "ph='" & request("ph3") & "' "
end if
'dH
if oprindelse = "ok" or ph = "ok" then strSQL = strSQL & ") and " end if
if dh = "ok" then strSQL = strSQL & "(" end if
if request("dh1") <> "" then
strSQL = strSQL & "dh='" & request("dh1") & "' "
end if
if request("dh1") <> "" and request("dh2") <> "" then strSQL = strSQL & "or
" end if
if request("dh2") <> "" then
strSQL = strSQL & "dh='" & request("dh2") & "' "
end if
if request("dh2") <> "" and request("dh3") <> "" then strSQL = strSQL & "or
" end if
if request("dh3") <> "" then
strSQL = strSQL & "dh='" & request("dh3") & "' "
end if
if request("dh3") <> "" and request("dh4") <> "" then strSQL = strSQL & "or
" end if
if request("dh4") <> "" then
strSQL = strSQL & "dh='" & request("dh4") & "' "
end if
if request("dh4") <> "" and request("dh5") <> "" then strSQL = strSQL & "or
" end if
if request("dh5") <> "" then
strSQL = strSQL & "dh='" & request("dh5") & "' "
end if
'Temperatur
if oprindelse = "ok" or ph = "ok" or dh = "ok" then strSQL = strSQL & ") and
" end if
if temp = "ok" then strSQL = strSQL & "(" end if
if request("temp1") <> "" then
strSQL = strSQL & "temp='" & request("temp1") & "' "
end if
if request("temp1") <> "" and request("temp2") <> "" then strSQL = strSQL &
"or " end if
if request("temp2") <> "" then
strSQL = strSQL & "temp='" & request("temp2") & "' "
end if
if request("temp2") <> "" and request("temp3") <> "" then strSQL = strSQL &
"or " end if
if request("temp3") <> "" then
strSQL = strSQL & "temp='" & request("temp3") & "' "
end if
if request("temp3") <> "" and request("temp4") <> "" then strSQL = strSQL &
"or " end if
if request("temp4") <> "" then
strSQL = strSQL & "temp='" & request("temp4") & "' "
end if
'Omraade
if oprindelse = "ok" or ph = "ok" or dh = "ok" or temp = "ok" then strSQL =
strSQL & ") and " end if
if omr = "ok" then strSQL = strSQL & "(" end if
if request("omr1") <> "" then
strSQL = strSQL & "omr='" & request("omr1") & "' "
end if
if request("omr1") <> "" and request("omr2") <> "" then strSQL = strSQL &
"or " end if
if request("omr2") <> "" then
strSQL = strSQL & "omr='" & request("omr2") & "' "
end if
if request("omr2") <> "" and request("omr3") <> "" then strSQL = strSQL &
"or " end if
if request("omr3") <> "" then
strSQL = strSQL & "omr='" & request("omr3") & "' "
end if
if request("omr3") <> "" and request("omr4") <> "" then strSQL = strSQL &
"or " end if
if request("omr4") <> "" then
strSQL = strSQL & "omr='" & request("omr4") & "' "
end if
if request("omr4") <> "" and request("omr5") <> "" then strSQL = strSQL &
"or " end if
if request("omr5") <> "" then
strSQL = strSQL & "omr='" & request("omr5") & "' "
end if
'Størelse
if oprindelse = "ok" or ph = "ok" or dh = "ok" or temp = "ok" or omr = "ok"
then strSQL = strSQL & ") and " end if
if str = "ok" then strSQL = strSQL & "(" end if
if request("str1") <> "" then
strSQL = strSQL & "str='" & request("str1") & "' "
end if
if request("str1") <> "" and request("str2") <> "" then strSQL = strSQL &
"or " end if
if request("str2") <> "" then
strSQL = strSQL & "str='" & request("str2") & "' "
end if
if request("str2") <> "" and request("str3") <> "" then strSQL = strSQL &
"or " end if
if request("str3") <> "" then
strSQL = strSQL & "str='" & request("str3") & "' "
end if
if request("str3") <> "" and request("str4") <> "" then strSQL = strSQL &
"or " end if
if request("str4") <> "" then
strSQL = strSQL & "str='" & request("str4") & "' "
end if
if request("str4") <> "" and request("str5") <> "" then strSQL = strSQL &
"or " end if
if request("str5") <> "" then
strSQL = strSQL & "str='" & request("str5") & "' "
end if
'Minimum akvarie-størrelse
if oprindelse = "ok" or ph = "ok" or dh = "ok" or temp = "ok" or omr = "ok"
or str = "ok" then strSQL = strSQL & ") and " end if
if mastr = "ok" then strSQL = strSQL & "(" end if
if request("mastr1") <> "" then
strSQL = strSQL & "mastr='" & request("mastr1") & "' "
end if
if request("mastr1") <> "" and request("mastr2") <> "" then strSQL = strSQL
& "or " end if
if request("mastr2") <> "" then
strSQL = strSQL & "mastr='" & request("mastr2") & "' "
end if
if request("mastr2") <> "" and request("mastr3") <> "" then strSQL = strSQL
& "or " end if
if request("mastr3") <> "" then
strSQL = strSQL & "mastr='" & request("mastr3") & "' "
end if
if request("mastr3") <> "" and request("mastr4") <> "" then strSQL = strSQL
& "or " end if
if request("mastr4") <> "" then
strSQL = strSQL & "mastr='" & request("mastr4") & "' "
end if
if request("mastr4") <> "" and request("mastr5") <> "" then strSQL = strSQL
& "or " end if
if request("mastr5") <> "" then
strSQL = strSQL & "mastr='" & request("mastr5") & "' "
end if
if mastr = "ok" then strSQL = strSQL & ")" end if
' Udfør forespørgsel (rs indeholder nu resultatet)
Set rs = Conn.Execute(strSQL)
if (rs.bof or rs.eof) then
Response.Write "Der er ingen fisk med disse krav."
else
Do
Response.Write rs("latinnavn") & "<br>"
' Gå til næste Record i rs
rs.MoveNext
' Fortsæt indtil rs er gennemløbet (EOF = End Of File)
Loop While Not rs.EOF
end if
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
%>
