请教关于 asp 参数传递 怎么传不过来

来源:百度知道 编辑:UC知道 时间:2024/09/22 23:36:49
这是teacher.asp中的片段
<% set rs=server.createobject("adodb.recordset")
sql="select id,t_name,t_zhicheng,t_xuewei,t_job from teacher where t_level<>6 order by t_level asc"
rs.open sql,conn,1,1
%>

<% do while not rs.eof %>
<tr height="18">
<td><a href="tdetail.asp?uid=<%=rs("id")%>"><%=rs("t_name")%</a></td>
<td> <%=rs("t_zhicheng")%></td>
<td> <%=rs("t_xuewei")%></td>
<td><p align="center"><%=rs("t_job")%></p></td>
</tr>
<%
rs.movenext
loop
rs.close

sql="select t_name from teacher where id=uid"
改为sql="select t_name from teacher where id='"&request("uid")&"'"

sql="select t_name from teacher where id=uid"

改成 sql="select t_name from teacher where id = " & uid

你用超链接的形式也就是GET方法提交的变量
所以接收的时候被当做字符串处理
也就是说uid=request("uid")是一个字符串
在SQL查询中要用"&&"引用字符串变量

如下:sql="select t_name from teacher where id="&uid&""

如果你在表单中用POST方法提交就不会有这种问题

如果teacher.asp正常显示
程序是没什么问题,你确定
<a href="tdetail.asp?uid=<%=rs("id")%>">
?是英文状态下的