0
나는 사용자 검색 쿼리와 같은 데이터베이스 단어를 찾는 고전적인 asp에서 매우 간단한 검색 쿼리를 만들고있다.이 간단한 고전적인 ASP 검색 쿼리가 작동하지 않는 이유는 무엇입니까?
"테스트"를 검색 할 때 내 웹 페이지에 결과가 없다고 말하고 있습니다. 그러나 나는 나의 데이터베이스에서 볼 수있는 검색이라는 특정 게시물을 가지고있다.
이것이 작동하지 않는 이유는 확실하지 않습니다.
<% option explicit %>
<!DOCTYPE HTML>
<html>
<head>
<link href="normalize.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--#include file="header.asp"-->
<!--#include file="dbconn.asp"-->
<%
dim stage, s, sql, info
stage = request.querystring("stage")
if stage = "" then stage=1
'------------------------------------------------------------------
if stage = 1 then
'------------------------------------------------------------------
response.write "<form action=""search.asp"" method=""get"">" &_
"<input type=""hidden"" name=""stage"" value=""2"">"&_
"<input type=""text"" id=""search"" name=""search"">" &_
"<input type=""submit"" value=""Search"">" &_
"</form>"
'------------------------------------------------------------------
elseif stage = 2 then
'------------------------------------------------------------------
'--- grab the data from the form
dim search
search = Request.QueryString("search")
'--- execute the query
' 0 1 2
SQL = " select ID, projectName, Description from projectstable"&_
" where (projectName like ' %search% ' or description like ' %search% ')"
set info=conn.execute(sql)
if info.eof then
response.write " <div class=""box2"">"&chr(13)
response.write " Sorry, no records matching your query"&chr(13)
response.write " </div>"&chr(13)
else
response.write "<div class=""list"">" &_
"<table>" &_
"<tr>" &_
"<th>Title</th><th>Post</th>" &_
"</tr>"
do
response.write "<tr>" &_
"<td>"&info(1)&"</td><td>"&info(2)&"</td>"&_
"</tr>"
info.movenext
loop until info.eof
response.write "</table></div>"
end if
'------------------------------------------------------------------
end if ' stage
'------------------------------------------------------------------
response.write "<br clear=""left""><br>"
if stage=2 then
response.write "<i>that's all folks!</i><br><br>"&_
"<a href=""search.asp"">Search again</a> | "
end if
response.write "<a href=""./"">back to main page</a>"
conn.close
%>
</div>
</body>
</html>
감사합니다. 나는 그것을 기억하기 전에 그것을 배웠다. SQL 주입 팁에 감사드립니다. 이것은 내부의 대학 과제 일 뿐이므로 괜찮을 것입니다.하지만 저는 그것에 대해 조사 할 것입니다. – chap