03. januar 2008 - 21:51Der er
44 kommentarer og 1 løsning
Hvorfor altid loop? Hjælp mig!
Hej... Ja hvorfor kommer altid et fejl, men jeg kan ikke finder hvor er fejl ellers måske mangler noget?
Håber kan får hjælp med det en løst problem?
::FEJL:: Microsoft VBScript compilation error '800a040e'
'loop' without 'do'
/menu-demo/menu.asp, line 99
loop ^
<% Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.RecordSet") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.mappath("test.mdb")
'flyt op/ned dir = Request.QueryString("dir") if dir <> "" then oldId = Request.QueryString("id") tempID = 0 if dir = "op" then newID = Int(oldId) - 1 else newID = Int(oldId) + 1 end if
SQL = "UPDATE menuer SET submenuID = " & tempID & " WHERE submenuID = " & oldID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & oldID & " WHERE submenuID = " & newID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & newID & " WHERE submenuID = " & tempID Conn.Execute(SQL) end if
'Udskriv formen.. 'Man er vist nød til at hendte max submenuID for der ikke sker fejl..: SQL = "SELECT max(submenuID) as maxID FROM menuer" set rs = conn.Execute(SQL) maxID = rs("maxID")
SQL = "SELECT navn, link, hidden, submenuID FROM menuer ORDER BY submenuID" set rs = conn.Execute(SQL)
if (rs.BOF OR rs.EOF) then %> <table style="border-left-width: 0px; border-right-width: 0px" id="table4"> <tr> <td style="border-style: none; border-width: medium"> <font face="Verdana" color="#FF0000" size="2"><b>Hallo - ingen sker noget i menu...</b></font></td> </tr> </table> <% else
Do while NOT (rs.BOF or rs.EOF)
Farve = 0 Do Until rs.EOF If farve=1 Then bg="#EBF1F8" Farve= Farve + 1 Else bg="#FFFFFF" farve=1 End If %> <table border="1" id="table1" style="border-width: 0px"> <tr> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="38" align="center"> <font face="Verdana" style="font-size: 9pt">()</font></td> <% if Int(rs("submenuID")) > 1 then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=op&id="<% rs("submenuID") %>><img border="0" src="images/gfx_icon/pilop.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if if Int(rs("submenuID")) < Int(maxID) then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=ned&id="<% rs("submenuID") %>><img border="0" src="images/gfx_icon/pilned.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center"> <% if rs("hidden") = 1 then %><IMG SRC="images/gfx_icon/online.gif" alt="Arkiv" BORDER="0"> <% Else %> <IMG SRC="images/gfx_icon/offline.gif" alt="Arkiv ikke" BORDER="0"> </td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="290"><% rs("navn") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="250"><% rs("link") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Redigere</td> <% IF rs("id") <> "1" THEN %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Slet;</td> <% end if %> </tr> <% rs.MoveNext loop %> </table> <% Conn.Close %>
<% Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.RecordSet") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.mappath("test.mdb")
'flyt op/ned dir = Request.QueryString("dir") if dir <> "" then oldId = Request.QueryString("id") tempID = 0 if dir = "op" then newID = Int(oldId) - 1 else newID = Int(oldId) + 1 end if
SQL = "UPDATE menuer SET submenuID = " & tempID & " WHERE submenuID = " & oldID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & oldID & " WHERE submenuID = " & newID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & newID & " WHERE submenuID = " & tempID Conn.Execute(SQL) end if
'Udskriv formen.. 'Man er vist nød til at hendte max submenuID for der ikke sker fejl..: SQL = "SELECT max(submenuID) as maxID FROM menuer" set rs = conn.Execute(SQL) maxID = rs("maxID")
SQL = "SELECT navn, link, hidden, submenuID FROM menuer ORDER BY submenuID" set rs = conn.Execute(SQL)
if (rs.BOF OR rs.EOF) then %> <table style="border-left-width: 0px; border-right-width: 0px" id="table4"> <tr> <td style="border-style: none; border-width: medium"> <font face="Verdana" color="#FF0000" size="2"><b>Hallo - ingen sker noget i menu...</b></font></td> </tr> </table> <% else
Jeg tror at fejlen skyldes fejl i dine "IF-ELSE-END IF"-sætninger..
Lav en kopi af filen, og erstat din kode med:
<% Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.RecordSet") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.mappath("test.mdb")
'flyt op/ned dir = Request.QueryString("dir") if dir <> "" then oldId = Request.QueryString("id") tempID = 0 if dir = "op" then newID = Int(oldId) - 1 else newID = Int(oldId) + 1 end if
SQL = "UPDATE menuer SET submenuID = " & tempID & " WHERE submenuID = " & oldID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & oldID & " WHERE submenuID = " & newID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & newID & " WHERE submenuID = " & tempID Conn.Execute(SQL) end if
'Udskriv formen.. 'Man er vist nød til at hendte max submenuID for der ikke sker fejl..: SQL = "SELECT max(submenuID) as maxID FROM menuer" set rs = conn.Execute(SQL) maxID = rs("maxID")
SQL = "SELECT navn, link, hidden, submenuID FROM menuer ORDER BY submenuID" set rs = conn.Execute(SQL)
if (rs.BOF OR rs.EOF) then %> <table style="border-left-width: 0px; border-right-width: 0px" id="table4"> <tr> <td style="border-style: none; border-width: medium"> <font face="Verdana" color="#FF0000" size="2"><b>Hallo - ingen sker noget i menu...</b></font></td> </tr> </table> <% else
Do while NOT (rs.BOF or rs.EOF)
Farve = 0 'Do Until rs.EOF If farve=1 Then bg="#EBF1F8" Farve= Farve + 1 Else bg="#FFFFFF" farve=1 End If %> <table border="1" id="table1" style="border-width: 0px"> <tr> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="38" align="center"> <font face="Verdana" style="font-size: 9pt">()</font></td> <% if Int(rs("submenuID")) > 1 then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=op&id="<% rs("submenuID") %>><img border="0" src="images/gfx_icon/pilop.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if if Int(rs("submenuID")) < Int(maxID) then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=ned&id="<% rs("submenuID") %>><img border="0" src="images/gfx_icon/pilned.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center"> <% if rs("hidden") = 1 then %> <IMG SRC="images/gfx_icon/online.gif" alt="Arkiv" BORDER="0"> <% Else %> <IMG SRC="images/gfx_icon/offline.gif" alt="Arkiv ikke" BORDER="0"> </td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="290"><% rs("navn") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="250"><% rs("link") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Redigere</td> <% End If IF rs("id") <> "1" THEN %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Slet;</td> <% end if %> </tr> <% rs.MoveNext Loop End If %> </table> <% Conn.Close %>
Brug CInt til konvertering til et tal, husk at teste for ikke-numereriske værdier..
oldId = Request.QueryString("id") if IsNumeric(oldId) = false or oldId = "" or oldId = null then response.write "Fejl i værdi (oldId)!" conn.close response.end ' afslutter ud skrivningen end if oldId = CInt(oldId)
Så kan du nøjes med:
if dir = "op" then newID = oldId - 1 else newID = oldId + 1 end if
Jeg har lige lavet en test, og der ser ud til at Len (som returnere længden af en streng) er den eneste pålidelig måde at finde ud af, om der er skrevet noget i querystring..
Denne her kode skulle gerne udskrive noget tekst, og nogle "--------------" linier hen over skærmen:
<% Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.RecordSet") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.mappath("test.mdb")
'flyt op/ned dir = Request.QueryString("dir") if Len(dir) > 0 Then response.write "Følgende står i DIR: " & dir & "<hr>" oldId = Request.QueryString("id") tempID = 0 if dir = "op" then newID = CInt(oldId) - 1 else newID = CInt(oldId) + 1 end if
SQL = "UPDATE menuer SET submenuID = " & tempID & " WHERE submenuID = " & oldID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & oldID & " WHERE submenuID = " & newID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & newID & " WHERE submenuID = " & tempID Conn.Execute(SQL) Else response.write "Der står ikke noget i DIR!<hr>" end if
'Udskriv formen.. 'Man er vist nød til at hendte max submenuID for der ikke sker fejl..: SQL = "SELECT max(submenuID) as maxID FROM menuer" set rs = conn.Execute(SQL) maxID = rs("maxID") response.write "maxID: " & maxID & "<hr>"
SQL = "SELECT navn, link, hidden, submenuID FROM menuer ORDER BY submenuID" set rs = conn.Execute(SQL)
if (rs.BOF OR rs.EOF) then response.write "Der er ingen poster i databasen!" %> <table style="border-left-width: 0px; border-right-width: 0px" id="table4"> <tr> <td style="border-style: none; border-width: medium"> <font face="Verdana" color="#FF0000" size="2"><b>Hallo - ingen sker noget i menu...</b></font></td> </tr> </table> <% else response.write "Udskriver posterne:<hr>" Dim c c = 0 Do while NOT (rs.BOF or rs.EOF) c = c + 1
Farve = 0 'Do Until rs.EOF If farve=1 Then bg="#EBF1F8" Farve= Farve + 1 Else bg="#FFFFFF" farve=1 End If %> <table border="1" id="table1" style="border-width: 0px"> <tr> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="38" align="center"> <font face="Verdana" style="font-size: 9pt">()</font></td> <% if CInt(rs("submenuID")) > 1 then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=op&id="<% rs("submenuID") %>><img border="0" src="images/gfx_icon/pilop.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if if CInt(rs("submenuID")) < CInt(maxID) then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=ned&id="<% rs("submenuID") %>><img border="0" src="images/gfx_icon/pilned.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center"> <% if CInt(rs("hidden")) = 1 then %> <IMG SRC="images/gfx_icon/online.gif" alt="Arkiv" BORDER="0"> <% Else %> <IMG SRC="images/gfx_icon/offline.gif" alt="Arkiv ikke" BORDER="0"> </td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="290"><% rs("navn") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="250"><% rs("link") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Redigere</td> <% End If IF rs("id") <> "1" THEN %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Slet;</td> <% end if %> </tr> <% rs.MoveNext Loop response.write "Der er udskrevet " & c & " poster<hr>" End If %> </table> <% Conn.Close response.write "Forbindelsen er nu lukket" %>
oldId = Request.QueryString("id") if Len(oldId) = 0 then response.write "Fejl i værdi (oldId)!" conn.close response.end ' afslutter ud skrivningen end if oldId = CInt(oldId) tempID = 0 if dir = "op" then newID = oldId - 1 else newID = oldId + 1 end if
virker ikke.. men jeg kan viser dig.. men kun op og ned.. men jeg har et andre mappe.. men du kan se der meget virker http://www.paaj.dk/menu_test/ der er før test under "submenuID" er OK uden problem.... så bagefter andre http://www.paaj.dk/menu-demo/ som Admin.. men er problem stadig..
<% Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.RecordSet") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.mappath("test.mdb")
'flyt op/ned
oldId = Request.QueryString("id") if Len(oldId) = 0 then response.write "Fejl i værdi (oldId)!" conn.close response.end ' afslutter ud skrivningen end if oldId = CInt(oldId) tempID = 0 if dir = "op" then newID = oldId - 1 else newID = oldId + 1 end if
SQL = "UPDATE menuer SET submenuID = " & tempID & " WHERE submenuID = " & oldID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & oldID & " WHERE submenuID = " & newID Conn.Execute(SQL) SQL = "UPDATE menuer SET submenuID = " & newID & " WHERE submenuID = " & tempID Conn.Execute(SQL) Else response.write "Der står ikke noget i DIR!<hr>" end if
'Udskriv formen.. 'Man er vist nød til at hendte max submenuID for der ikke sker fejl..: SQL = "SELECT max(submenuID) as maxID FROM menuer" set rs = conn.Execute(SQL) maxID = rs("maxID") response.write "maxID: " & maxID & "<hr>"
SQL = "SELECT navn, link, hidden, submenuID FROM menuer ORDER BY submenuID" set rs = conn.Execute(SQL)
if (rs.BOF OR rs.EOF) then response.write "Der er ingen poster i databasen!" %> <table style="border-left-width: 0px; border-right-width: 0px" id="table4"> <tr> <td style="border-style: none; border-width: medium"> <font face="Verdana" color="#FF0000" size="2"><b>Hallo - ingen sker noget i menu...</b></font></td> </tr> </table> <% else response.write "Udskriver posterne:<hr>" Dim c c = 0 Do while NOT (rs.BOF or rs.EOF) c = c + 1
Farve = 0 'Do Until rs.EOF If farve=1 Then bg="#EBF1F8" Farve= Farve + 1 Else bg="#FFFFFF" farve=1 End If %> <table border="1" id="table1" style="border-width: 0px"> <tr> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="38" align="center"> <font face="Verdana" style="font-size: 9pt">()</font></td> <% if CInt(rs("submenuID")) > 1 then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=op&id="<%=rs("submenuID") %>"><img border="0" src="images/gfx_icon/pilop.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if if CInt(rs("submenuID")) < CInt(maxID) then %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" align="center"> <a href="?dir=ned&id="<%=rs("submenuID") %>"><img border="0" src="images/gfx_icon/pilned.gif"></a> </td> <% else %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="24" ><img border='0' src='null.gif'><td> <% end if %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center"> <% if CInt(rs("hidden")) = 1 then %> <IMG SRC="images/gfx_icon/online.gif" alt="Arkiv" BORDER="0"> <% Else %> <IMG SRC="images/gfx_icon/offline.gif" alt="Arkiv ikke" BORDER="0"> </td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="290"><%=rs("navn") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="250"><%=rs("link") %></td> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Redigere</td> <% End If IF rs("submenuID") <> "1" THEN %> <td bgcolor="<%=bg%>" style="border-style: none; border-width: medium" width="30" align="center">Slet;</td> <% end if %> </tr> <% rs.MoveNext Loop response.write "Der er udskrevet " & c & " poster<hr>" End If %> </table> <% Conn.Close response.write "Forbindelsen er nu lukket" %>
ja ved.. men kun test.. men før første gang meget fint.. men derfor vi har laver om deer.. og meget fint.. men hvis jeg laver om det som billede måske skade.. jeg HADER.. og kan du får 100 point nu ?
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.