Recommended: Functions that filter illegal characters in asp % Functioncutbadchar(str) badstr=No|text|ming|character|column|format' Fill in uncivilized words here, use|separate badword=split(badstr,|) Fori=0toUbound(badword) Ifstr(str,badword(i))0then str=Replace(str,badword(i),***) EndIf Next cutbadchar=str EndFunct
Many websites now use the method of generating static pages, because the access speed will be improved (the server-side CPU utilization rate is very low), and it is also easy to be included by search engines. However, one problem this brings is that you need enough space to store these static pages. If your space is not very rich and you want to be included by search engines, you can actually use a pseudostatic method. For example, the path of showarticle.asp?id1=1&id2=2 can be converted to showarticle/?1-2.htm (of course it can be converted to other forms). The specific method is as follows:
Preparation: Create file index.asp, folder showarticle, and create file index.asp (/index.asp, /showarticle, /showarticle/index.asp) in folder showarticle.
<html><head>
<title>==========index.asp==========Show article list file</title>
</head>
<body>
<%
'Database call code, omitted here
%>
<li><a href=showarticle/?<%=rs(id1)%>-<%=rs(id2)%>.htm><%=rs(title)%></a></li>
</body>
</html>
<html><head>
<title>======= showarticle/index.asp==========Showarticle/index.asp======Show article content file</title>
</head>
<body>
<%
Dim value1, value2, id1, id2
value1=replace(Request.ServerVariables(QUERY_STRING),.htm,) 'Get the following parameters
value2=split(value1,-) 'Filter the parameters to obtain the values of id1 and id2
id1=value2(0)
id2=value2(1)
'Next call the database and display the content, just like dynamic ASP
%>
</body>
</html>
Principle analysis: First, use Request.ServerVariables(QUERY_STRING) to obtain the parameters after ?, such as showarticle/?1-2.htm to receive 1-2.htm, and then filter 1-2.htm. The parameters we need to obtain are 1 and 2. Next, search 1 and 2 in the database, just like dynamic ASP.
Share: Solutions when including single quotes in ASP query conditions When we are building ASP websites, query is often the most basic function, but we know that single quotes are used to represent character-type data in ASP query statements, and must be used in double use. If only one single quote is used, there will definitely be an error. Regarding this phenomenon, I provide my solution below. In fact, in ASP, if there are single quotes in the keywords to be queryed, you only need to use