ASP程序变量调用失败

来源:百度知道 编辑:UC知道 时间:2024/09/25 00:40:45
跪求啊。。。各位大哥谁知道的指点下啊。

我有个页面用了个网上下的分页程序,这个分页程序用dim定义了后边要用的所有变量(页面为Dim.asp),我想可能这就是问题的所在。我发部分代码:

<!--#include file="A1B1/Dim.asp"-->
<%
'获取记录总数
sql="select count(id) as idcount from m where n='快餐外卖'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,0,1
idcount=rs("idcount")'获取记录总数

if(idcount>0) then'如果记录总数=0,则不处理
if(idcount mod pages=0)then'如果记录总数除以每页条数有余数,则=记录总数/每页条数+1
pagec=int(idcount/pages)'获取总页数
else
pagec=int(idcount/pages)+1'获取总页数
end if

'获取本页需要用到的id============================================
'读取所有记录的id数值。
sql="select id from m where n='快餐外卖' order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1

以上是正常的代码。大家注意看我在程序里边有2处用过“快餐外卖”这个字符串。我现在就是要把这个字符串用变量代替。但是用变量就出问题。
<

select count(id) as idcount from m where n=n

大概你的意思是 "select count(id) as idcount from m where n='" & n & "'"

可能哦~不确定

<a href="shi.asp?n=快餐外卖">快餐外卖 </a>,

sql="select count(id) as idcount from m where n='"&n&"'"

因为是字串 n='' 要加单引号的