][SQL Server]第 1 行: '=' 附近有语法错误。
][SQL Server]第 1 行: '=' 附近有语法错误。/showvote.asp, 第 6 行
原代码
<!--#include file="const.asp"-->
<!--#include file="Conn/conn.asp"-->
<%classid=request("classid")
set rs=server.createobject("adodb.recordset")
set rs=conn.execute("select title from class where id="& classid)
title=rs("title")
rs.close
sql="select * from vote where class="& classid
rs.open sql,conn,3,1
totalcount=0
do while not rs.eof
totalcount=totalcount+rs("count")
rs.movenext
loop
totalren=totalcount
if totalcount=0 then
totalcount=1
end if
%>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="STYLE.CSS">
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, "ËÎÌå"}
-->
</style>
</head>
<body>
<div align="center">
<center>
<table border="0" width="600" bordercolorlight="#000000" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" height="73" bgcolor="#FFFFFF">
<tr>
<td width="596" colspan="3" height="23">
<p align="center"><b><font color=#0066cc><%=title%></font></b>
</td>
</tr>
<%rs.movefirst
do while not rs.eof%>
<tr>
<td height="23" width="164">
<p align="center"><%=rs("vote")%></td>
<%h=(rs("count")*300)/totalcount%>
<td height="23" width="300" valign="middle">
<table border="0" width="<%=h%>" height="13" bgcolor="<%=rs("color")%>" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="100%" style="border-style: solid; border-width: 1" valign="middle"></td>
</tr>
</table>
</td>
<td height="23" width="129">
<p align="center"><font color=green><%=rs("count")%></font> ?¡À(<%=cint((rs("count")*10000)/totalcount)/100%>%)</td>
</tr>
<%rs.movenext
loop%>
<tr>
<td width="596" colspan="3" height="21"> <span class="style1"></span>
<p align="center">12¨®D¨ª??¡À<b><font color=red><%=totalren%></font></b>¨¨?¡ä?</td>
</tr>
</table>
</center>
</div>
<p align="center"></p>
<p align="center"> </p> --------------------编程问答-------------------- classid没值 --------------------编程问答-------------------- 赞成孟子老大所说的. --------------------编程问答-------------------- 在SQL里已经吧classid的默认值设为一了``还是出现同样的错误!! --------------------编程问答-------------------- 数据库中设置无用,classid=request("classid"),这个地方要判断一下 --------------------编程问答-------------------- set rs=conn.execute("select title from class where id="& classid)
而且不能把获取来的值直接放在sql语句中,典型的注入漏洞。 --------------------编程问答-------------------- id加个[id] --------------------编程问答-------------------- where id='" & classid & "' "
--------------------编程问答-------------------- set rs=conn.execute("select title from class where id="& classid)
改成
set rs=conn.execute("select title from class where id='"& classid & "'") --------------------编程问答-------------------- 可以了``谢谢~各位~
补充:.NET技术 , ASP.NET