★★再给100分:搜索单字符时总会出搜索出些不相关的东西? 附加二进制声明BINARY field_name = '字' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SELECT * FROM tablename WHERE BINARY UCASE(fieldname) like UCASE('%".$Key."%') 搜索核心代码是$lookartsql="select artID from article where ".$selectart." like '%".$keyword1."%'";请问UCASE()是自定义函数吗?我使用时出错说没有定义 $lookartsql="select artID from article where BINARY ".$selectart." like '%".$keyword1."%'"; 这个也和mysql的编码有关系.你把 mysql 的 /etc/my.cnf (UNIX) 或者 winnt\my.ini (WINNT/2000/XP) 中的[mysqld] 部分添加一句default-character-set = gbk试试. 感谢 xuzuning(唠叨) phanx(向右走) ,问题已解决,可以结贴了 还是有问题,如果加了BINARY,就不能忽略大小搜索,从而又会导致不能搜索出一些该搜索出来的东西 select artID from article where INSTR(字段, '值')>0 先判断关键字,分中文和英文搜索语句,中文加BINARY,英文不用。 to:countstars(深空) 中英文混合查询呢? 没办法,目前MYSQL对中文的支持不太好,只好寄希望于MYSQL的新版本了 ASP//search.htm<HTML><HEAD><TITLE>文件搜索引擎</TITLE></HEAD><BODY><CENTER><FORM METHOD=POST ACTION="search.asp"><TABLE BGCOLOR="#CC6633" BORDER="0"><TR> <TD> <FONT COLOR="#FFFFFF"> 请输入所要搜索的字符串: <INPUT TYPE="text" NAME="SearchText" SIZE="22"></FONT> </TD> <TD><INPUT TYPE="submit" VALUE="确定"> <INPUT TYPE="reset" VALUE="清除"></TD></tr></TABLE></FORM></CENTER></BODY></HTML>//search.asp<HTML><HEAD><TITLE>'<%=Request("SearchText")%>'的搜索结果</TITLE></HEAD><BODY><B>'<%=Request("SearchText")%>'的搜索结果</B><BR><%Const fsoForReading = 1Dim objFile, objFolder, objSubFolder, objTextStreamDim bolCase, bolFileFound, bolTagFoundDim strCount, strDeTag, strExt, strFile, strContent, strRoot, strTag, strText, strTitle, strTitleLstrFile = ".asp .htm .html .js .txt .css"strRoot = "/"strText = Request("SearchText")strTag = Chr(37) & Chr(62)bolFileFound = FalsebolTagFound = FalseIf Request("Case") = "on" Then bolCase = 0 Else bolCase = 1Set objFSO = Server.CreateObject("Scripting.FileSystemObject")RealPath=Server.MapPath(strRoot)VirtualPath="http://" & Request.ServerVariables("SERVER_NAME") Set objFolder = objFSO.GetFolder(RealPath)schSubFol(objFolder)Sub schSubFol(objFolder)on error resume nextFor Each objFile in objFolder.Files If strText = "" Then Exit Sub If Response.IsClientConnected Then Set objTextStream = objFSO.OpenTextFile(objFile.Path,fsoForReading) strContent = objTextStream.ReadAll If InStr(1, strContent, strTag, bolCase) Then Else If Mid(objFile.Name, Len(objFile.Name) - 1, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 1, 2) If Mid(objFile.Name, Len(objFile.Name) - 2, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 2, 3) If Mid(objFile.Name, Len(objFile.Name) - 3, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 3, 4) If Mid(objFile.Name, Len(objFile.Name) - 4, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 4, 5) If InStr(1, strContent, strText, bolCase) And Instr(1, strFile, strExt, 1) Then If InStr(1, strContent, "<TITLE>", 1) Then strTitle = Mid(strContent, InStr(1, strContent, "<TITLE>", 1) + 7, InStr(1, strContent, "</TITLE>", 1)) Else strTitle = "未命名" end if myFile=objFile.Path myFile=replace(myfile,RealPath,VirtualPath,1,-1,1) myFile=replace(myfile,"\","/") strCount = strCount + 1 Response.Write "<DL><DT><B><I>"& strCount &"</I></B> - <A HREF=" & myFile & ">" & strTitle & "</A></A></DT><BR><DD>" strTitleL = InStr(1, strContent, "</TITLE>", 1) - InStr(1, strContent, "<TITLE>", 1) + 7 strDeTag = "" bolTagFound = False Do While InStr(strContent, "<") bolTagFound = True strDeTag = strDeTag & " " & Left(strContent, InStr(strContent, "<") - 1) strContent = MID(strContent, InStr(strContent, ">") + 1) Loop strDeTag = strDeTag & strContent If Not bolTagFound Then strDeTag = strContent Response.Write replace(Mid(strDeTag, strTitleL, 200),strText,"<font color=red>" & strText & "</font>",1,-1,bolcase) Response.Write "...<BR><b><FONT SIZE='2'>URL: " & myFile Response.Write " - 上次修改时间: " & objFile.DateLastModified Response.Write " - " & FormatNumber(objFile.Size / 1024) Response.Write "Kbytes</FONT></b></DD></DL>" bolFileFound = True End If objTextStream.Close End If End IfNextEnd SubFor Each objSubFolder in objFolder.SubFolders schSubFol(objSubFolder)NextIf Not bolFileFound then Response.Write "没有匹配结果"If bolFileFound then Response.Write "<B>搜索结束</B>"Set objTextStream = NothingSet objFolder = NothingSet objFSO = Nothing%></BODY></HTML> 还是有问题,如果加了BINARY,就不能忽略大小搜索,从而又会导致不能搜索出一些该搜索出来的东西 php输出打印页面换页, php新人求助,如何调用dll 去掉数字和字母问题,在线等 高分请教大家详细设计在开发过程中的使用. 谈者有分,不够继续追加 zend core是什么东西?好像是收费的? 刚才求SQL的那贴给错分了,请Clayborne(Clay)兄进来接分 php设计网站过程 有关zend的问题? 怎么自己做的页面打不开? 有没有一个函数,能够获得单元格的宽度? ===GD 的配置 为啥我搞不定=== 请问如何获得这个页面编辑器的编辑区的内容?
$lookartsql="select artID from article where ".$selectart." like '%".$keyword1."%'";请问UCASE()是自定义函数吗?我使用时出错说没有定义
你把 mysql 的 /etc/my.cnf (UNIX) 或者 winnt\my.ini (WINNT/2000/XP) 中的[mysqld] 部分添加一句
default-character-set = gbk
试试.
<HTML>
<HEAD>
<TITLE>文件搜索引擎</TITLE>
</HEAD>
<BODY>
<CENTER>
<FORM METHOD=POST ACTION="search.asp">
<TABLE BGCOLOR="#CC6633" BORDER="0">
<TR>
<TD> <FONT COLOR="#FFFFFF">
请输入所要搜索的字符串:
<INPUT TYPE="text" NAME="SearchText" SIZE="22"></FONT> </TD>
<TD><INPUT TYPE="submit" VALUE="确定">
<INPUT TYPE="reset" VALUE="清除"></TD>
</tr>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
//search.asp
<HTML>
<HEAD>
<TITLE>'<%=Request("SearchText")%>'的搜索结果</TITLE>
</HEAD>
<BODY>
<B>'<%=Request("SearchText")%>'的搜索结果</B><BR>
<%
Const fsoForReading = 1
Dim objFile, objFolder, objSubFolder, objTextStream
Dim bolCase, bolFileFound, bolTagFound
Dim strCount, strDeTag, strExt, strFile, strContent, strRoot, strTag, strText, strTitle, strTitleL
strFile = ".asp .htm .html .js .txt .css"
strRoot = "/"
strText = Request("SearchText")
strTag = Chr(37) & Chr(62)
bolFileFound = False
bolTagFound = False
If Request("Case") = "on" Then bolCase = 0 Else bolCase = 1
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
RealPath=Server.MapPath(strRoot)
VirtualPath="http://" & Request.ServerVariables("SERVER_NAME")
Set objFolder = objFSO.GetFolder(RealPath)
schSubFol(objFolder)
Sub schSubFol(objFolder)
on error resume next
For Each objFile in objFolder.Files
If strText = "" Then Exit Sub
If Response.IsClientConnected Then
Set objTextStream = objFSO.OpenTextFile(objFile.Path,fsoForReading)
strContent = objTextStream.ReadAll
If InStr(1, strContent, strTag, bolCase) Then
Else
If Mid(objFile.Name, Len(objFile.Name) - 1, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 1, 2)
If Mid(objFile.Name, Len(objFile.Name) - 2, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 2, 3)
If Mid(objFile.Name, Len(objFile.Name) - 3, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 3, 4)
If Mid(objFile.Name, Len(objFile.Name) - 4, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 4, 5)
If InStr(1, strContent, strText, bolCase) And Instr(1, strFile, strExt, 1) Then
If InStr(1, strContent, "<TITLE>", 1) Then
strTitle = Mid(strContent, InStr(1, strContent, "<TITLE>", 1) + 7, InStr(1, strContent, "</TITLE>", 1))
Else
strTitle = "未命名"
end if
myFile=objFile.Path
myFile=replace(myfile,RealPath,VirtualPath,1,-1,1)
myFile=replace(myfile,"\","/")
strCount = strCount + 1
Response.Write "<DL><DT><B><I>"& strCount &"</I></B> - <A HREF=" & myFile & ">" & strTitle & "</A></A></DT><BR><DD>"
strTitleL = InStr(1, strContent, "</TITLE>", 1) - InStr(1, strContent, "<TITLE>", 1) + 7
strDeTag = ""
bolTagFound = False
Do While InStr(strContent, "<")
bolTagFound = True
strDeTag = strDeTag & " " & Left(strContent, InStr(strContent, "<") - 1)
strContent = MID(strContent, InStr(strContent, ">") + 1)
Loop
strDeTag = strDeTag & strContent
If Not bolTagFound Then strDeTag = strContent
Response.Write replace(Mid(strDeTag, strTitleL, 200),strText,"<font color=red>" & strText & "</font>",1,-1,bolcase)
Response.Write "...<BR><b><FONT SIZE='2'>URL: " & myFile
Response.Write " - 上次修改时间: " & objFile.DateLastModified
Response.Write " - " & FormatNumber(objFile.Size / 1024)
Response.Write "Kbytes</FONT></b></DD></DL>"
bolFileFound = True
End If
objTextStream.Close
End If
End If
Next
End Sub
For Each objSubFolder in objFolder.SubFolders
schSubFol(objSubFolder)
Next
If Not bolFileFound then Response.Write "没有匹配结果"
If bolFileFound then Response.Write "<B>搜索结束</B>"
Set objTextStream = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
</BODY></HTML>