Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal, preciso que ajudem-me a alterar meu código. To fazendo um site no DW usando php/mysql. Fiz um sistema de busca para o cliente pesquisar por palavra-chave, mas quando fui testar, percebi que o mecanismo não aceita palavras acentuadas, ou seja, só traz resultados de palavras sem acentos inseridas no form. Eu peguei um código que promete resolver o problema, mas não estou conseguindo adaptá-lo à minha página.
MINHA PÁGINA
// inicio da página
<?php require_once('Connections/connPMMC.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$search_rsResultado = "-1";
if (isset($_GET['search'])) {
$search_rsResultado = $_GET['search'];
}
mysql_select_db($database_connPMMC, $connPMMC);
$query_rsResultado = sprintf("SELECT * FROM noticias WHERE noticias.texto LIKE %s ORDER BY noticias.noticia_ID DESC", GetSQLValueString("%" . $search_rsResultado . "%", "text"));
$rsResultado = mysql_query($query_rsResultado, $connPMMC) or die(mysql_error());
$row_rsResultado = mysql_fetch_assoc($rsResultado);
$totalRows_rsResultado = mysql_num_rows($rsResultado);
?>
// aqui está o head e todo o html
<?php
mysql_free_result($rsResultado);
?>
// fim da página
E a função que achei na internet é essa:
busca=split(request("palavra"),chr(32))
dim onde
for x = 0 to Ubound(busca)
if x > 0 then
onde=onde + " and "
end if
pesq=busca(x)
pesq = replace(pesq,"a","[a,á,à,ã,â,ä,A]")
pesq = replace(pesq,"e","[e,é,è,ê,ë,E]")
pesq = replace(pesq,"i","[i,í,ì,î,ï,I]")
pesq = replace(pesq,"o","[o,ó,ò,õ,ô,ö,O]")
pesq = replace(pesq,"u","[u,ú,ù,û,ü,U]")
pesq = replace(pesq,"c","[c,ç]")
onde=onde+"texto like '%" & pesq & "%'"
next
sql = "select * from texto where " & onde
Alguém poderia me ajudar? Saberiam inserir essa função na minha página?
Valeu,
Leandro
Carregando comentários...