Hej
JAg har en funktion som ska ändra lite kod åt mig men jag får det inte att fungera.
Här är funktionen
FUNCTION fixaKod( txtcontent, mall, titel, forfattare, indexera, nyckelord, datumStart, datumSlut, con, publicering )
' öppna Recordset
Set hamtaMallRS = Server.CreateObject( "ADODB.Recordset" )
hamtaMallRS.ActiveConnection = Con
hamtaMallRS.CursorType = 3
hamtaMallRS.Open "SELECT * FROM mallar WHERE mall_id=" & mall
IF NOT hamtaMallRS.EOF THEN
mallKod = hamtaMallRS( "mall_kod" )
END IF
' stäng Recordset
hamtaMallRS.Close
set hamtaMallRS = nothing
IF publicering <> "1" THEN
kod = kod + "<" + "% IF date < #"& datumStart &"# OR(date > #"& datumSlut &"#) THEN" & vbcrlf
kod = kod + "response.redirect ""../400.asp""" & vbcrlf
kod = kod + "END IF %"+ ">" & vbcrlf
END IF
'Lägg till mallkoden
kod = kod + mallKod
kod = replace(kod, "[kod]", txtContent)
kod = replace(kod, "[titel]", titel)
kod = replace(kod, "[nyheter]", "<" & "!--#include file=""nyheter.asp""--" & ">")
kod = replace(kod, "[meny]", "<" & "!--#include file=""49.asp""--" & ">")
kod = replace(kod, "[forfattare]", forfattare)
kod = replace(kod, "[skapad]", date)
kod = replace(kod, "[logga]", "<img name=""logo"" src=""../bilder/system/logo.gif"">")
IF Instr(kod,"<head>")>0 Then
dim metakod
IF indexera = "1" THEN
metakod = "<head>" & vbcrlf
metaKod = metakod + "<meta name=""robots"" content=""index"">" & vbcrlf
metaKod = metaKod + "<meta name=""keywords"" content="""& nyckelord &""">" & vbcrlf
ELSE
metakod = "<head>" & vbcrlf
metaKod = "<meta name=""robots"" content=""noindex"">" & vbcrlf
END IF
IF metaKod <> "" THEN
kod = replace(kod, "<head>", metakod)
END IF
END IF
'Gör om tidspublicerade länkar
tidLank1 = "<"&"% Set con2 = Server.CreateObject(""ADODB.Connection"")"&vbcrlf &_
"con2.Open Application(""cmdatabas"")" &vbcrlf &_
"Set lankRS = Server.CreateObject( ""ADODB.Recordset"" )" &vbcrlf &_
"lankRS.ActiveConnection = Con2" &vbcrlf &_
"lankRS.CursorType = 3" &vbcrlf &_
"lankRS.Open ""SELECT * FROM sidor WHERE sida_id="
tidlank2 = """" &vbcrlf &"IF NOT lankRS.EOF THEN" &vbcrlf &_
"IF NOT date() < cDate(lankRS( ""sida_datum_start"" )) THEN" &vbcrlf &_
"IF NOT date() > cDate(lankRS( ""sida_datum_slut"" )) THEN %"&">" &vbcrlf
tidlank3 = ""&vbcrlf&"<"&"% END IF" &vbcrlf &_
"END IF" &vbcrlf &_
"END IF" &vbcrlf &_
"lankRS.close" &vbcrlf &_
"set lankRS = nothing" &vbcrlf &_
"con2.close" &vbcrlf &_
"set con2 = nothing %"&">" &vbcrlf
kod = replace(kod, "[<!--<ID=", tidlank1)
kod = replace(kod, ">-->Lank<!--<", tidlank2)
kod = replace(kod, "[END IF]>-->]", tidlank3)
'Slut tidspublicerade länkar
'''''''''''''''''''''''''''''''''''
END FUNCTION
Så här anroppar jag funktionen:
kod= fixaKod( txtcontent, mall, titel, forfattare, indexera, nyckelord , datumStart, datumSlut, con, publicering )
Jag får felmeddelandet:
Feltyp:
Körningsfel i Microsoft VBScript (0x800A000D)
Inkompatibla typer: 'fixaKod'