哪位好心人帮我看看,在线跪等!
<!--#include file= "conn.asp " -->
<%
OpenDB()
%>
<%
dim sql,rs,cid
cid=request.QueryString( "id ")
%>
<% If cid= " " Then response.Write( "非法登陆 ")%>
<% Else %>
<%
sql= "select content from TravelNews where id= "&cid& " "
set rs=conn.execute(sql)
%>
<% End If %>
<p class= "read "> <%=rs( "content ")%> </p>
<% CloseDB() %>
错误类型:
Microsoft VBScript 编译器错误 (0x800A03EA)
语法错误
/read.asp, line 19
Else
帮我看看那里有问题,小第谢谢了!!
------解决方案-------------------- <% If cid= " " Then response.Write( "非法登陆 ")%>
改成
<% If cid= " " Then
response.Write( "非法登陆 ")%>
再试试
------解决方案--------------------sql= "select content from TravelNews where id= "&cid& " "这个改成下面这样
sql= "select content from TravelNews where id= ' "&cid& " ' "或是改成这样试试
sql= "select content from TravelNews where id= "&cid
------解决方案-------------------- <% If cid= " " Then 这里换一行
response.Write( "非法登陆 ")%>
<% Else %>
<%
sql= "select content from TravelNews where id= "&cid& " "
set rs=conn.execute(sql)
%>
<% End If %>
------解决方案-------------------- <!--#include file= "conn.asp " -->
<%
OpenDB()
dim sql,rs,cid
cid=request.QueryString( "id ")
If cid= " " Then
response.Write( "非法登陆 ")
Else
sql= "select content from TravelNews where id= "&cid& " "
set rs=conn.execute(sql)
%>
<p class= "read "> <%=rs( "content ")%> </p>
<%
End If
CloseDB()
%>
你用上面一段程序就不会错了。
你在写这段程序的时候犯了以下几个错误:
(1)在写VBScript代码的时候尽量多的合并 <%%> 符号,如:
<%
OpenDB()
%>
<%
dim sql,rs,cid
cid=request.QueryString( "id ")
%>
要合并成
<%
OpenDB()
dim sql,rs,cid
cid=request.QueryString( "id ")
%>
(2)在使用If ... Else ... End If循环时,必须符合以下规则:
If <表示式> Then
<执行语句>
Else
<执行语句>
End If
而不能这样写:
If <表示式> Then <执行语句>
Else
<执行语句>
End If
你的代码里,如果把 <%%> 缩减掉的话,就成下面的代码了:
<%
If cid= " " Then response.Write( "非法登陆 ")
Else
sql= "select content from TravelNews where id= "&cid& " "
set rs=conn.execute(sql)
End If
%>