fejl i if kommande
hej allesammen har et lille problem!!! jeg har en skrevet denne her kode og den virker fint på min egen maskine men ligeså snart den kommer op på serveren fungere det ikke! koden er her:<% response.buffer = true %>
<!-- #include file="usercheck.asp" -->
<HTML>
<HEAD>
<LINK HREF="../style/style.css" REL="stylesheet" type="text/css">
</HEAD>
<BODY CLASS="main">
<SCRIPT LANGUAGE="JavaScript">
function clickHandler() {
var targetId, srcElement, targetElement;
srcElement = window.event.srcElement;
if (srcElement.className == "Outline") {
targetId = srcElement.id + "details";
targetElement = document.all(targetId);
if (targetElement.style.display == "none") {
targetElement.style.display = "";
} else {
targetElement.style.display = "none";
}
}
}
document.onclick = clickHandler;
</SCRIPT>
<% Mode = Request("mode")
'-- create news --
if mode = "create" Then %>
<FORM ACTION="news.asp?mode=create" METHOD="post">
<%
'creates connection to database
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../db.mdb")
'if the user have submitted the formular
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
'checks to make sure all fields have been filled out
if (Request.Form("headline") <> "" AND Request.Form("body") <> "" AND Request.Form("narrator") <> "") then
strbody = Replace(request("body"),vbCrLf,"<BR>")
If request.Form("morebody") <> "" Then
strMoreBody = Replace(request("morebody"),vbCrLf,"<BR>")
End If
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "select * from news"
rs.Open strsql, conn, 1, 3
rs.AddNew
If Request.Form("bold") = "on" Then
strheadline = "<B>" & request.Form("Headline") & "</B>"
rs("headline") = replace(strheadline,"'","''")
Else
rs("headline") = replace(Request.Form("headline"),"'","''")
End If
rs("body") = replace(strbody,"'","''")
If request.Form("morebody") <> "" Then
rs("moreBody") = Replace(strmorebody,"'","''")
End If
rs("narrator") = Replace(Request("narrator"),"'","''")
rs("date") = Request.Form("date")
rs.update
Response.Write "<FONT COLOR=""green"">you have added the topic to the news section</FONT><BR>"
rs.Close
set rs = nothing
else
Response.Write"<FONT COLOR='red'>Some fields haven't been filled out</font><BR>"
end if
end if
%>
Headline:<BR>
<input name="headline" type="text" size="40" CLASS="field"> <INPUT TYPE="CHECKBOX" NAME="bold" CLASS="field"> bold<BR>
The news topic:<BR>
<textarea cols="39" rows="13" name="body" CLASS="field"></textarea><BR>
<FONT COLOR="#0099ff">
<span id=Out1 class=Outline style="cursor: hand; ">
Include more function
</span></font>
<div id="Out1details" style="display:None; position:relative;">
Text to be displayed after click on more function:<BR>
<textarea cols="39" rows="13" name="morebody" CLASS="field"></textarea>
</div><BR>
Narrator:<br>
<INPUT TYPE="text" NAME="narrator" size="40" CLASS="field"><BR>
date:<BR>
<INPUT TYPE="text" NAME="date" size="40" CLASS="field"><BR>
<BR><INPUT TYPE="submit" VALUE="Create topic" CLASS="button"><BR><INPUT TYPE="reset" VALUE="Restart" CLASS="button">
</FORM>
<%
conn.close
set conn = nothing
%>
<BR>
<A HREF="news.asp">back</A><BR>
<A HREF="mainsite.asp">Back To Mainsite</A>
<%
'--Show news--
Elseif Mode = "show" Then
' Connecting to database
Set Con = Server.CreateObject("ADODB.Connection")
DBPath = "DBQ=" & server.mappath("../db.mdb")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBPath
' extracting the chosen topic from Database
sql = "SELECT * From news Where Id = " & Request.Querystring("id")
Set rs = Con.Execute(Sql)
%>
<TABLE WIDTH="450" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD CLASS="lefttop"> <%= rs("headline")%></TD>
<TD ALIGN="right" CLASS="righttop"><%= rs("date")%></TD>
</TR>
<TR>
<TD COLSPAN="2"><%= rs("body")%></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="left"><I>Written By <%= rs("narrator")%></I></TD>
</TR>
</TABLE>
<%
If rs("morebody") <>"" Then
sql2 = "SELECT * From news Where Id = " & Request.Querystring("id")
Set rs2 = Con.Execute(Sql2)
%>
<BR>
After click on "more" button:<BR>
<TABLE WIDTH="450" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD CLASS="lefttop"> <%= rs2("headline")%></TD>
<TD ALIGN="right" CLASS="righttop"><%= rs2("date")%></TD>
</TR>
<TR>
<TD COLSPAN="2"><%= rs2("morebody")%></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="left"><I>Written By <%= rs2("narrator")%></I></TD>
</TR>
</TABLE>
<%
End If
rs.Close
Set rs = Nothing
con.close
set con = nothing
%>
<BR>
<A HREF="news.asp">back</A><BR>
<A HREF="mainsite.asp">Back To Mainsite</A>
<%
'-- Change news --
Elseif mode = "change" Then
' connecting to Database
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../db.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strDSN
' writing search criteria
sql ="SELECT * FROM news Where Id=" & Request.Querystring("ID")
Set rs = Conn.Execute(sql)
%>
<FORM ACTION="news.asp?mode=changed&id=<%=rs("id")%>" METHOD="post">
Headline:<BR>
<input name="headline" type="text" size="40" VALUE="<% = rs("headline") %>" CLASS="button"> <INPUT TYPE="CHECKBOX" NAME="bold" CLASS="field"> bold<BR>
The news topic:<BR>
<textarea cols="39" rows="13" name="body" CLASS="button"><% = rs("body") %></textarea><BR>
Narrator:<br>
<INPUT TYPE="text" NAME="narrator" VALUE="<% = rs("narrator") %>" size="40" CLASS="field"><BR>
date:<BR>
<INPUT TYPE="text" VALUE="<% = rs("date") %>" NAME="date" size="40" CLASS="field"><BR>
<BR><INPUT TYPE="submit" VALUE="Change topic" CLASS="button"><BR><INPUT TYPE="reset" VALUE="Restart" CLASS="button">
</FORM>
<BR>
<A HREF="news.asp">back</A><BR>
<A HREF="mainsite.asp">Back To Mainsite</A>
<%
'-- changed --
Elseif Mode = "changed" Then
' Connecting to Database
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../db.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strDSN
If Request.Form("bold") = "on" Then
strheadline = "<B>" & Request.Form("headline") & "</B>"
Else
strheadline = Request.Form("headline")
End If
' writing new values to the changed news topic
sql = "UPDATE news SET headline = '" & replace(strheadline,"'","''") & "'"
sql = sql & ", body= '" & Replace(replace(request.form("body"),"'","''"),vbCrLf,"<BR>") &"'"
sql = sql & "WHERE Id = " & request("ID")
Set rs = Conn.Execute(sql)
Conn.Close
Response.Redirect ("news.asp")
%>
<%
'--front page--
else
' Connecting to Database
Set Con = Server.CreateObject("ADODB.Connection")
DBPath = "DBQ=" & server.mappath("../db.mdb")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBPath
' selecting what we wish to wiev from the database
sql = "SELECT * From news ORDER BY Id DESC"
Set rs = Con.Execute(Sql)
%>
<B>Actions:</B><BR>
<A HREF="news.asp?mode=create">Create a new subject to the news section</A><BR><BR>
<B>news in the database:</B><BR>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<% Do While Not rs.EOF %>
<TR>
<TD><a href="news.asp?mode=show&id=<%=rs("id")%>">Show information</A></TD>
<TD ALIGN="right"><%= rs("headline") %> -
<script language="JavaScript">
function PopWin(url,h,w) {
popupWin = window.open(url, 'popup', 'height=' + h + ',width=' + w + ',top=100,left=80')
}
//
</script>
<A HREF="java script:PopWin('deletenews.asp?id=<%= rs("id") %>',120,135);">delete</A>
</TD>
</TR>
<%
rs.MoveNext
loop
rs.Close
Set rs = Nothing
con.close
set con = nothing
%>
</TABLE>
<BR>
<A HREF="mainsite.asp">Back To Mainsite</A><BR><BR>
<B>Please read this info:</B><BR>
if you want to insert a link use this bit of code:<BR>
<INPUT SIZE="60" TYPE="text" VALUE="<A HREF=HTTP://www.thelink.dk>this is the link</A>">
<% End If %>
</BODY>
</HTML>
------------
for denne fejlmeddelelse:
Microsoft VBScript compilation error '800a0400'
Expected statement
/update/admin/news.asp, line 288
End If
er ved at blive idiot over det ikke fungere!!! har rodet med det så mange timer nu! PLEASE HJÆLP!!
