永发信息网

谁来帮帮我?ASP写的站内搜索在哪错了?

答案:4  悬赏:70  手机版
解决时间 2021-07-30 01:45
  • 提问者网友:泪痣哥哥
  • 2021-07-29 06:46

index.html 代码:

-------------------------------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
*{
margin:0;
padding:0;
}
ul{
list-style-type:none
clear:left;
margin:20px;
}
li{
float:left;
text-align:center
width:160px;
}
.label_Name{
width:100px;
height:25px;
font-size:14px
}

-->
</style>
</head>

<body>
<form action="search.asp" method="get" target="_self">
<ul>
<li class="label_name"><label for="keywords">站内搜索:</label></li>
<li><input type="text" id="keywords" name="keywords" /></li>
<li><input type="submit" value="查询" /></li>
</ul>
</form>
</body>
</html>
-------------------------------------------------------------------------------------------------------

search.asp 如下:

-------------------------------------------------------------------------------------------------------

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="Inc/conn.asp" -->
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%
dim rs,sql,keywords
keywords=Server.CreateObject("keywords")
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from zhigong where name like '%"&keywords&"%' order by id desc"
rs.open sql,conn,1,1
Response.Write("姓名&nbsp;&nbsp;工资<br />")
do while not rs.eof
Response.Write(rs("name"))
Response.Write("&nbsp;&nbsp;")
Response.Write(rs("gongzi"))
Response.Write("<br />")
rs.movenext
loop
%>
</body>
</html>

---------------------------------------------------------------------------------------------------------

conn.asp 如下:

---------------------------------------------------------------------------------------------------------

<%
dim conn
dim connstr
dim db
db="admin\database\Enterprise.mdb"
set conn = server.createobject("adodb.connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data source=" & server.MapPath(db)
conn.Open connstr
sub Closeconn()
conn.close
set conn=nothing
end sub
%>

--------------------------------------------------------------------------------------------------------

  • 错误类型:
    Server 对象, ASP 0177 (0x800401F3)
    无效的类别字符串
    /search.asp, 第 13 行

  • 浏览器类型:
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2)

  • 网页:
    GET /search.asp

  • 时间:
    2009年12月13日, 10:30:09
  • 最佳答案
    • 五星知识达人网友:上分大魔王
    • 2021-07-29 07:54
    看了下,这话错误!keywords=Server.CreateObject("keywords"),没见过这样定义变量的!
    全部回答
    • 1楼网友:有你哪都是故乡
    • 2021-07-29 10:42
    keywords=Server.CreateObject("keywords") 这句错了! 应该这样;keywords=request.Form("keywords")
    • 2楼网友:深街酒徒
    • 2021-07-29 09:29
    keywords=request.querystring("keywords")
    • 3楼网友:青灯有味
    • 2021-07-29 08:17
    keywords=Server.CreateObject("keywords") .这不对。keywords=request.Form("keywords") 前面<form action="search.asp" method="get" target="_self" 改成post
    我要举报
    如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
    点此我要举报以上问答信息
    大家都在看
    推荐资讯