代码分析
我的这段代码有没有错<%
Dim id,Rs,SQL
Dim Hits,r_hits,z_hits,y_hits,HitsTime,stype
If Not IsNumeric(Request("id")) And Request("id") <> "" then
Response.Write"错误的系统参数!ID必须是数字"
Response.End
Else
id = CLng(Request.querystring("id"))
End If
stype = CLng(Request.querystring("type"))
If Not IsObject(Conn) Then ConnectionDatabase
Set Rs = Server.CreateObject("ADODB.Recordset")
sql="select Hits,r_hits,z_hits,y_hits,HitsTime from Article where id="& id
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
If Not Rs.EOF Then
hits = CLng(Rs("hits"))+1
Rs("hits").Value = hits
If DateDiff("Ww", Rs("HitsTime"), Now()) <= 0 Then
Rs("r_hits").Value = Rs("r_hits").Value + 1
Else
Rs("r_hits").Value = 1
End If
If DateDiff("M", Rs("HitsTime"), Now()) <= 0 Then
Rs("z_hits").Value = Rs("z_hits").Value + 1
Else
Rs("z_hits").Value = 1
End If
If DateDiff("D", Rs("HitsTime"), Now()) <= 0 Then
Rs("y_hits").Value = Rs("y_hits").Value + 1
Else
Rs("y_hits").Value = 1
Rs("HitsTime").Value = Now()
End If
Rs.Update
Hits = Rs("Hits")
r_hits = Rs("r_hits")
z_hits = Rs("z_hits")
y_hits = Rs("y_hits")
End If
Rs.close
set Rs=nothing
CloseConn
If stype = 1 Then
Response.Write "var oHits=document.getElementById(""ArticleHits"");" & vbNewLine
Response.Write "if (oHits!=null) {" & vbNewLine
Response.Write "oHits.innerHTML="& Chr(34) &"本日:"& r_hits &" 本周:"& z_hits &" 本月:"& y_hits &" 总数:"& Hits &" "& Chr(34) &"" & vbNewLine
Response.Write "}" & vbNewLine
Else
Response.Write "document.write ("& Chr(34) &"本日:"& r_hits &" 本周:"& z_hits &" 本月:"& y_hits &" 总数:"& Hits &" "& Chr(34) &");"
End If
%>